Closed mtoohey31 closed 5 months ago
I think the proper solution would probably be to make sure hidden names translate to C names that are distinguished from normal variable names in all cases. This particular probably has to do with ascii encoding .
.
My understanding of what's happening, and why the patch above seems to fix things, is that a name is made into a "hidden" name by prepending .
, or made into a "padding" name by prepending .padding
. But when the identifier already begins with padding
, names that are meant to be considered just plain "hidden" are also considered "padding", which breaks things.
Do you know if there's a reason why names are marked as "hidden" or "padding" by prepending strings instead of something else like extra field(s) in the Name type? I don't know much about how the compiler works so there might be a reason I'm not aware of. But if there isn't, the prefix approach does seem kind of brittle, so maybe a better way to fix the issue would be to add extra field(s) to the Name type to distinguish between "hidden", "padding", etc. instead of the prefixes?
But my question is why is it hiding padding?
I think the intent is that everywhere a name is hidden it is also prefixed, so that it is unique. A name shouldn't be hidden without being also prefixed. (i.e. your variable padding
should never become .padding
). I think this invariant isn't respected in src/Common/Unique.hs at line 59. Adding the prefix unique to the baseName there seems to fix the problem in general.
Ah, I see. Yeah, if we ensured that hidden names were prefixed then it sounds like that would prevent the issue.
Thanks for the report ! This is fixed in the latest dev
.
Great, thanks for the fix!
It seems like the use of the "padding" prefix to signify a padding name in
src/Common/Name.hs
is problematic. If I attempt to build the following (somewhat contrived) source:I get this error:
However, if I apply the following patch:
...then the error is resolved. Is the approach in the patch an acceptable solution, or is there a more elegant way to fix this? Also, could the same problem arise with cctx names (mentioned right below padding names in
Name.hs
)? I haven't attempted to reproduce the issue for that case yet but it seems like it might be possible.