diff --git a/parser-typechecker/src/Unison/PrintError.hs b/parser-typechecker/src/Unison/PrintError.hs index cf08b7e7a..851ea6802 100644 --- a/parser-typechecker/src/Unison/PrintError.hs +++ b/parser-typechecker/src/Unison/PrintError.hs @@ -375,17 +375,14 @@ renderTypeError e env src curPath = case e of -- , (,Color.ForceShow) <$> rangeForType foundType -- , (,Color.ForceShow) <$> rangeForType expectedType -- , - (,Type1) <$> rangeForAnnotated foundLeaf, + (,Type1) <$> rangeForAnnotated foundType, (,Type2) <$> rangeForAnnotated expectedLeaf ], fromOverHere' src [styleAnnotated Type1 foundLeaf] - [styleAnnotated Type1 mismatchSite], - if giveUnitHint then - "\nNote: actions within a block must have type " <> - style Type2 (renderType' env expectedLeaf) <> ".\n" - else "", + [styleAnnotated Type1 expectedLeaf], + unitHint, intLiteralSyntaxTip mismatchSite expectedType, debugNoteLoc . mconcat @@ -405,6 +402,10 @@ renderTypeError e env src curPath = case e of debugSummary note ] where + unitHintMsg = + "\nNote: actions within a block must have type " <> + style Type2 (renderType' env expectedLeaf) <> ".\n" + unitHint = if giveUnitHint then unitHintMsg else "" giveUnitHint = case expectedType of Type.Ref' u | u == unitRef -> case mismatchSite of Term.Let1Named' v _ _ -> Var.isAction v diff --git a/unison-src/transcripts/fix2354.output.md b/unison-src/transcripts/fix2354.output.md index 2ff17a4ee..ccf433a97 100644 --- a/unison-src/transcripts/fix2354.output.md +++ b/unison-src/transcripts/fix2354.output.md @@ -11,13 +11,10 @@ x = 'f ```ucm - I found a value of type: (a1 ->{𝕖} a1) ->{𝕖} Nat + I found a value of type: (a1 ->{𝕖} a1) ->{𝕖} Nat where I expected to find: (a -> 𝕣1) -> 𝕣 1 | f : (forall a . a -> a) -> Nat - 2 | f id = id 0 - 3 | - 4 | x = 'f from right here: diff --git a/unison-src/transcripts/fix614.output.md b/unison-src/transcripts/fix614.output.md index b703471a6..e213cb83a 100644 --- a/unison-src/transcripts/fix614.output.md +++ b/unison-src/transcripts/fix614.output.md @@ -33,11 +33,12 @@ ex2 = do ```ucm - I found a value of type: a ->{Stream a} Unit + I found a value of type: a ->{Stream a} Unit where I expected to find: Unit 2 | Stream.emit - 3 | 42 + + Note: actions within a block must have type Unit. ``` @@ -92,15 +93,16 @@ ex4 = ```ucm - I found a value of type: [Nat] + I found a value of type: [Nat] where I expected to find: Unit 2 | [1,2,3] -- no good - 3 | () from right here: 2 | [1,2,3] -- no good + Note: actions within a block must have type Unit. + ``` diff --git a/unison-src/transcripts/fix693.output.md b/unison-src/transcripts/fix693.output.md index e32d18b6d..6a7549757 100644 --- a/unison-src/transcripts/fix693.output.md +++ b/unison-src/transcripts/fix693.output.md @@ -42,12 +42,10 @@ h0 req = match req with ```ucm - I found a value of type: Optional a1 + 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 - 3 | { X.x _ c -> _ } -> handle c with h0 from right here: diff --git a/unison-src/transcripts/hello.output.md b/unison-src/transcripts/hello.output.md index 40f0a2045..8cd4f9b6d 100644 --- a/unison-src/transcripts/hello.output.md +++ b/unison-src/transcripts/hello.output.md @@ -83,7 +83,7 @@ hmm = "Not, in fact, a number" ```ucm - I found a value of type: Text + I found a value of type: Text where I expected to find: Nat 1 | hmm : .builtin.Nat