Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upInconsistent compiler behaviour, adding an identity function leading to different outcome #903
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Aug 27, 2017
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Aug 27, 2017
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
matekdk
Aug 27, 2017
It seems that debug statement is getting hold of the argument-next from the argument, while the execution of the method is calling the self-next method instead.
I think that in this case, the compiler should err with a message that there are two different "next" entities in the scope, and it does not know which one to choose.
matekdk
commented
Aug 27, 2017
|
It seems that I think that in this case, the compiler should err with a message that there are two different "next" entities in the scope, and it does not know which one to choose. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
zwilias
Aug 27, 2017
Member
The type-checker and the codegen disagree, leading to an incorrect result. The inner-most next should be the one used, which the type-checker does, but the codegen seems to think this is a recursive function and transforms it to a while loop instead.
@FRosner could you close the issue here and reopen it on elm-lang/elm-compiler instead? Thanks for the report!
|
The type-checker and the codegen disagree, leading to an incorrect result. The inner-most @FRosner could you close the issue here and reopen it on elm-lang/elm-compiler instead? Thanks for the report! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I think this is a known and reported issue. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
I opened elm/compiler#1636 instead. |
FRosner commentedAug 27, 2017
Problem
When a locally bound function and a global function have the same name
f, then using it asf ()or(identity f) ()yields different results.Context
I was trying to implement an ADT representing a circular list. This is what I had so far:
It works as expected and the following test case is green:
However as soon as I remove the
Debug.logand executenext ()directly the test never finishes. Looks like the identify call makes the compiler use the locally bound variable, while without, it takes the global function.See slack discussion for more details.
Environment
Workround
Don't name the local variable the same as the global.
Expected Behaviour