unison icon indicating copy to clipboard operation
unison copied to clipboard

Confusing error message refers to the wrong line

Open stew opened this issue 6 months ago • 0 comments

Describe and demonstrate the bug

type Tonya = Tonya
type Farah = Farah
type BugEyes =
type Ophelia = Ophelia

ability Extra where
  terrestrial: a

disguise : Tonya ->{Extra} BugEyes
disguise = bug "out"

urkle: Farah
urkle = 
  ignoredFarah: Farah
  ignoredFarah = bug "out"

  match disguise Tonya with
    Ophelia -> Farah

This code fails to compile, as it should The problem with this code is that the patterns match the wrong type. The return type of disguise is BugEyes, not Ophelia. However, the error message refers to the ignoredFarah line, and the type Farah as the incorrect line:

  I found a value  of type:  Ophelia
  where I expected to find:  BugEyes
  
      9 | disguise : Tonya ->{Extra} BugEyes
     10 | disguise = bug "out"
     11 | 
     12 | urkle: Farah
     13 | urkle = 
     14 |   ignoredFarah: Farah
     15 |   ignoredFarah = bug "out"
  
    from right here:
  
      4 | type Ophelia = Ophelia

Screenshots Image

stew avatar Apr 01 '25 03:04 stew