finos / morphir-elm

Tools to work with the Morphir IR in Elm.
https://package.elm-lang.org/packages/finos/morphir-elm/latest
Apache License 2.0
45 stars 63 forks source link

Morphir elm compiler does not enforce pattern match completeness #1148

Open edwardpeters opened 7 months ago

edwardpeters commented 7 months ago

Describe the bug Morphir elm will compile code with incomplete pattern matching. This can result in runtime errors.

To Reproduce The following code compiles:

type MyUnion = A | B

foo : MyUnion -> String
foo x = case x of
    A -> "A"

bar : Int -> String
bar i = foo B

When bar is run, it results in "Unable to compute", as makes sense given that the pattern match does not handle that case.

Expected behavior Type checking should enforce that pattern matching is exhaustive.

Desktop (please complete the following information):