-
Notifications
You must be signed in to change notification settings - Fork 21
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
Flaky analysis of intrinsic functions to ValIntrinsic #190
Comments
heats up |
I appear to get the same behaviour on 0.4.0, 74c7bb0 (also tested on 0.4.3). Note that the type analysis was updated in 0.5.0 . The rules for getting it to result in a Swapping the order of the two executable statements in |
The problem appears to be specific to the |
Moving the |
I can't see how the include inlining would effect it in any way, it's pretty simple (defined here) and won't effect any statement that isn't It does sound like the this initial analysis is where the problem lies. If it's not, the only other place I can think of is if this is a bug in uniplate's |
I've done more tests. I don't know why, but the disambiguator receives |
Huh. Changing |
Here's a MWE: subroutine main
integer*1 x, int1, a1, a2, a3, a4, a5, a6, a7, a8, a9
x = INT(int1, 2)
end This (incorrectly) parses the |
The problem is that during renaming, |
-- Rename an ExpValue variable, assuming that it is to be treated as a
-- reference to a previous declaration, possibly in an outer scope.
renameExp :: Data a => RenamerFunc (Expression (Analysis a))
renameExp e@(ExpValue _ _ (ValVariable v)) = maybe e (`setUniqueName` setSourceName v e) `fmap` getFromEnvs v
-- Intrinsics get unique names for each use.
renameExp e@(ExpValue _ _ (ValIntrinsic v)) = flip setUniqueName (setSourceName v e) `fmap` addUnique v NTIntrinsic
renameExp e = return e At the point the renamer runs, the intrinsic transformation pass hasn't yet run, so we only need to look at the We should be able to solve this with a check in |
Good debugging! I would favour a solution of changing the format of unique names in a way that avoids this altogether as opposed to checking whether it's present or not. There might be something I've not considered but I think putting an underscore between the symbol and the unique number would be sufficient. Aiui this is only an issue for symbols that end in a number. |
Good point, agreed. That should rule out this class of ambiguity bug where two different symbols generate the same unique name. On first thought I wondered if it wouldn't work for intrinsics like I'll make a PR updating the unique name schema & check it over with Dominic on Monday. Amusing bug, cheers @RaoulHC for the report and help! |
Previously, symbols like int and int1 could have the same unique name generated for them, depending on the fresh number used e.g. n=12: int -> int12; n=2: int1 -> int12. This can break things further up that expect unique names to be, well, unique. Adding a separator between the variable and the fresh number prevents this type of edge case from occurring. Also see the GitHub discussion for further info: #190
Previously, symbols like int and int1 could have the same unique name generated for them, depending on the fresh number used e.g. n=12: int -> int12; n=2: int1 -> int12. This can break things further up that expect unique names to be, well, unique. Adding a separator between the variable and the fresh number prevents this type of edge case from occurring. Also see the GitHub discussion for further info: #190
Discussed & above fix applied. |
Had discussed this with @raehik before, but this is a stripped down minimal working case of the analysis transformations
for
ExpFunctionCall
name nodes toValIntrinsics
being flaky and seems to be effected by completely unrelated lines.The following code:
Used to parse and print the following Fortran:
Will return the INT node as:
Deleting any line in the include file or fortran file will result in it being parsed as:
Reproduced this with b322458. Don't think this issue was present prior to 0.5.0 but not sure exactly where it was introduced.
The text was updated successfully, but these errors were encountered: