error message cleanup

whenever showing two mismatched types, ensure they are left aligned for easy visual comparison
This commit is contained in:
Paul Chiusano 2021-04-08 00:24:00 -05:00
parent 79fff8523e
commit 6181733dcb
3 changed files with 29 additions and 29 deletions

View File

@ -188,14 +188,13 @@ renderTypeError e env src = case e of
<> " has to be"
ExistentialMismatch {..} -> mconcat
[ Pr.wrap $ mconcat
[ preamble
, " "
, "Here, one is "
, style Type1 (renderType' env expectedType)
, " and another is "
, style Type2 (renderType' env foundType)
, ":"]
[ Pr.lines
[ Pr.wrap preamble
, ""
, "Here, one is: " <> style Type1 (renderType' env expectedType)
, "and another is: " <> style Type2 (renderType' env foundType)
, ""
]
, Pr.lineSkip
, showSourceMaybes src [mismatchSiteS, expectedLocS]
, fromOverHere' src
@ -255,13 +254,12 @@ renderTypeError e env src = case e of
solvedVars' = filter showVar solvedVars
in
mconcat [ Pr.lines
[ Pr.wrap $
"The " <> ordinal argNum <> " argument to the function " <>
Pr.backticked (style ErrorSite (renderTerm env f)) <> "has type"
, ""
, style Type2 (renderType' env foundType)
, "\n but I was expecting\n"
, style Type1 (renderType' env expectedType)
[ Pr.wrap $
"The " <> ordinal argNum <> " argument to " <>
Pr.backticked (style ErrorSite (renderTerm env f)),
"",
" has type: " <> style Type2 (renderType' env foundType),
" but I expected: " <> style Type1 (renderType' env expectedType)
, ""
, showSourceMaybes src
[ (, Type1) <$> rangeForAnnotated expectedType
@ -326,11 +324,10 @@ renderTypeError e env src = case e of
, debugSummary note
]
Mismatch {..} -> mconcat
[ "I found a value of type "
, style Type1 (renderType' env foundLeaf)
, " where I expected to find one of type "
, style Type2 (renderType' env expectedLeaf)
, ":\n\n"
[ Pr.lines [
"I found a value of type: " <> style Type1 (renderType' env foundLeaf),
"where I expected to find: " <> style Type2 (renderType' env expectedLeaf) ]
, "\n\n"
, showSourceMaybes
src
[ -- these are overwriting the colored ranges for some reason?

View File

@ -42,7 +42,8 @@ h0 req = match req with
```ucm
I found a value of type Optional a1 where I expected to find one of type Optional a:
I found a value of type: Optional a1
where I expected to find: Optional a
1 | h0 : Request {X t} b -> Optional b
2 | h0 req = match req with
@ -66,7 +67,11 @@ h1 req = match req with
```ucm
Each case of a match / with expression need to have the same
type. Here, one is Optional t and another is Optional b :
type.
Here, one is: Optional t
and another is: Optional b
3 | { X.x t _ -> _ } -> handle t with h1
4 | { d } -> Some d
@ -89,13 +94,10 @@ h2 req = match req with
```ucm
The 1st argument to the function `k` has type
The 1st argument to `k`
Nat
but I was expecting
a
has type: Nat
but I expected: a
3 | { Abort.abort -> k } -> handle k 5 with h2

View File

@ -83,7 +83,8 @@ hmm = "Not, in fact, a number"
```ucm
I found a value of type Text where I expected to find one of type Nat:
I found a value of type: Text
where I expected to find: Nat
1 | hmm : .builtin.Nat
2 | hmm = "Not, in fact, a number"