You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug morphir-elm make will report value cycles when none exist.
To Reproduce
The following code compiles in native elm but not in morphir-elm:
countA : Int -> Int
countA x =
if x == 0
then 0
else x + countB (x-1)
countB : Int -> Int
countB x =
if x == 0
then 0
else x + countA (x-1)
The following example demonstrates the same issue, but better isolates that it is specifically mutually recursive functions that cause this issue:
type IntCons =
Nil
| HeadTail Int IntCons
sum : IntCons -> Int
sum c =
case c of
Nil -> 0
HeadTail i tail -> i + redirect tail
redirect : IntCons -> Int
redirect x = sum x
Note that without the `redirect` function this is accepted.
Expected behavior
As this is not a true value cycle, the compiler should not reject it.
Desktop (please complete the following information):
OS: OSX
Version: 2.89.0
Additional context
While the example above is pointless, this is causing us an actual issue where we need a "dispatch" function that may send certain variants of a recursive type to particular handlers based on what else exists in the tree.
The text was updated successfully, but these errors were encountered:
edwardpeters
changed the title
Compiler improperly detects cycles
Compiler improperly detects cycles if mutually recursive functions are dfined
Feb 20, 2024
edwardpeters
changed the title
Compiler improperly detects cycles if mutually recursive functions are dfined
Compiler improperly detects cycles if mutually recursive functions are defined
Feb 20, 2024
Describe the bug
morphir-elm make
will report value cycles when none exist.To Reproduce
The following code compiles in native elm but not in morphir-elm:
The following example demonstrates the same issue, but better isolates that it is specifically mutually recursive functions that cause this issue:
Expected behavior
As this is not a true value cycle, the compiler should not reject it.
Desktop (please complete the following information):
Additional context
While the example above is pointless, this is causing us an actual issue where we need a "dispatch" function that may send certain variants of a recursive type to particular handlers based on what else exists in the tree.
The text was updated successfully, but these errors were encountered: