Skip to content

type errors can be wrong-kinded #5440

@ceedubs

Description

@ceedubs

Describe and demonstrate the bug

If an expression returns a value that doesn't have the same number of type parameters as the expected type, then the type error message is confusing and shows types with kind errors.

Instead of:

 I found a value  of type:  Either Text
  where I expected to find:  Optional

I would expect:

 I found a value  of type:  Either Text a
  where I expected to find:  Optional Nat

or something like that...I'm not quite sure what it should infer for the right side of the Either.

Input:

```ucm
fresh/main> builtins.merge
```

```unison
foo : Optional Nat
foo = Left "error"
```

Output:

``` ucm
fresh/main> builtins.merge

  Done.

```
``` unison
foo : Optional Nat
foo = Left "error"
```

``` ucm

  Loading changes detected in scratch.u.

  I found a value  of type:  Either Text
  where I expected to find:  Optional
  
      1 | foo : Optional Nat
      2 | foo = Left "error"
  

```



🛑

The transcript failed due to an error in the stanza above. The error is:


  I found a value  of type:  Either Text
  where I expected to find:  Optional
  
      1 | foo : Optional Nat
      2 | foo = Left "error"

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions