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
If an elm pattern match statement has nested list expressions, the generated scala code may improperly group them.
To Reproduce
Start with the following elm source code:
describe : List (List Int) -> String
describe ll = case ll of
(_ :: _) :: _ -> "This starts with a list of at least one element"
_ :: _ :: _ -> "This contains at least two sublists"
_ -> "Other"
listDescribeTest1 : Int -> String
listDescribeTest1 x = describe [[x]]
listDescribeTest2 : Int -> String
listDescribeTest2 x = describe [[], [x]]
describe operates on lists of lists. The first arm of the match statement should match any list which has a first element which itself has a first element. The second arm should then catch lists of at least two elements.
This is the behavior in both native elm and the morphir-elm interpreter, which show each of the first two arms being matched by listDescribeTest1 and listDescribeTest2 respectively.
However, if morphir-elm gen is called, the following scala code is produced for the describe function:
def describe(
ll: morphir.sdk.List.List[morphir.sdk.List.List[morphir.sdk.Basics.Int]]
): morphir.sdk.String.String =
ll match {
case _ :: _ :: _ =>
"This starts with a list of at least one element"
case _ :: _ :: _ =>
"This contains at least two sublists"
case _ =>
"Other"
}
Here, the grouping information has been lost and the first arm completely shadows the second. (In this example it will at least result in a scala compiler warning, but in others - such as if the second case were omitted - it would produce apparently legal scala code with the incorrect behavior.)
Expected behavior
Generated scala patterns should be grouped the same way as the elm source code.
Desktop (please complete the following information):
OS: OSX
Version: 2.87.6
The text was updated successfully, but these errors were encountered:
Describe the bug
If an elm pattern match statement has nested list expressions, the generated scala code may improperly group them.
To Reproduce
Start with the following elm source code:
describe
operates on lists of lists. The first arm of the match statement should match any list which has a first element which itself has a first element. The second arm should then catch lists of at least two elements.This is the behavior in both native elm and the morphir-elm interpreter, which show each of the first two arms being matched by
listDescribeTest1
andlistDescribeTest2
respectively.However, if
morphir-elm gen
is called, the following scala code is produced for the describe function:Here, the grouping information has been lost and the first arm completely shadows the second. (In this example it will at least result in a scala compiler warning, but in others - such as if the second case were omitted - it would produce apparently legal scala code with the incorrect behavior.)
Expected behavior
Generated scala patterns should be grouped the same way as the elm source code.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: