Skip to content

Morphir elm compiler does not enforce pattern match completeness #1148

@edwardpeters

Description

@edwardpeters

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):

  • OS: OSX
  • Version: 2.89.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    taskTask level project item

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions