Skip to content

Confusing type error in variant pattern match #434

Description

@LightAndLight

Example

$ cat test.ipso
test : Array a -> Bool
test items =
  case array.find (\_ -> false) of
    None () -> false
    Some _ -> true

$ ipso --check test.ipso
test.ipso:4:5: error: expected kind "Type", got kind "Row"
  |
4 |     None () -> false
  |     ^

The mistake is that I forgot to pass the array argument to array.find, so I'm trying to pattern match on a function Array a -> (| Some : a, None : () |).

If the scrutinee determines the type of the pattern, then the type error should be:

test.ipso:4:5: error: expected type "Array a -> (| Some : a, None : () |)", got type "(| None : (), r |)"
  |
4 |     None () -> false
  |     ^

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    UXUser experience.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions