Fix checkValidEnum
outputting non-unique names when cViaASM
is enabled
#89
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into a compiler failure when cross-compiling the following code to Windows via ASM.
https://github.com/input-output-hk/haskell-lmdb/blob/master/src/Database/LMDB/FFI.hsc#L159-L161
I saw 17
error: redefinition of...
errors in the log, and since there are 18 values in the enum I was defining, this lead me to believe something inhsc2hs
wasn't going right.Log: compilation error
After a little bit of digging, I found the problem is in
checkValidEnum
, and in particular lines309
and310
. Since in my example, I don't any define Haskell names for the values of the enum,hName
in line310
isNothing
, and so the name we pass tovalidConstTestViaAsm
is always going to benoKey
, and since none of the other parameters tovalidConstTestViaAsm
change, it will print the same line each time.hsc2hs/src/CrossCodegen.hs
Lines 306 to 319 in a6d9f73
The solution I'm proposing here is to use the (trimmed)
cName
when we have nohName
in scope. I'm not familiar with this code base, so let me know if this PR is okay as is.My temporary local "solution" is to just give Haskell names to each value of the enum.