Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localise module maps #286

Merged
merged 12 commits into from
Sep 4, 2024
Merged

Localise module maps #286

merged 12 commits into from
Sep 4, 2024

Conversation

dorchard
Copy link
Member

@dorchard dorchard commented Sep 3, 2024

A problem arose in CamFort with the location of declarations being misreported to the wrong file (camfort/camfort#185). It turns out this comes down to the structure of mod file analysis, where all the used modules get their name space inserted into the module map and so it cannot be distinguished whether a variable was declared in this module or an imported one. This PR fixes this by adding information into the NameType data structure about whether a variable is Local or Imported. A module map can then be 'localised' with localisedModuleMap which removes from a mod map any imported declarations. This fixes the bug in CamFort.
An accompanying test was added in ModFileSpec

The genUniqNameToFilenameMap :: ModFiles -> M.Map F.Name String applies this localisation.

@dorchard dorchard requested a review from mrd September 3, 2024 13:27
@dorchard
Copy link
Member Author

dorchard commented Sep 3, 2024

(note this is rebased off #285)

Copy link
Collaborator

@raehik raehik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Some of the pre-existing type synonyms I find hard to follow and might warrant extra documenting, but it's a minor nit.

main :: IO ()
main = do
args <- getArgs
(opts, parsedArgs) <- compileArgs args
case (parsedArgs, action opts) of
(paths, ShowMyVersion) -> do
putStrLn $ "fortran-src version: " ++ showVersion
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We should have a release guide that instructs updating the version string shown here. I'll start a wiki page later.)

src/Language/Fortran/Util/ModFile.hs Show resolved Hide resolved
@dorchard dorchard merged commit 185d4dc into master Sep 4, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants