@@ -74,6 +74,7 @@ import Unison.Util.AnnotatedText qualified as AT
74
74
import Unison.Util.ColorText (Color )
75
75
import Unison.Util.ColorText qualified as Color
76
76
import Unison.Util.Monoid (intercalateMap )
77
+ import Unison.Util.Monoid qualified as Monoid
77
78
import Unison.Util.Pretty (ColorText , Pretty )
78
79
import Unison.Util.Pretty qualified as Pr
79
80
import Unison.Util.Range (Range (.. ), startingLine )
@@ -328,6 +329,62 @@ renderTypeError e env src = case e of
328
329
" expression " ,
329
330
" need to have the same type."
330
331
]
332
+ FunctionUnderApplied {.. } ->
333
+ mconcat
334
+ [ Pr. lines
335
+ [ " I found a value of type: " <> style Type1 (renderType' env foundLeaf),
336
+ " where I expected to find: " <> style Type2 (renderType' env expectedLeaf),
337
+ " it looks like it might be a function application that's just missing these arguments:\n\n " ,
338
+ Monoid. intercalateMap " , " (style Type1 . renderType' env) needArgs
339
+ ],
340
+ " \n\n " ,
341
+ showSourceMaybes
342
+ src
343
+ [ -- these are overwriting the colored ranges for some reason?
344
+ -- (,Color.ForceShow) <$> rangeForAnnotated mismatchSite
345
+ -- , (,Color.ForceShow) <$> rangeForType foundType
346
+ -- , (,Color.ForceShow) <$> rangeForType expectedType
347
+ -- ,
348
+ (,Type1 ) . startingLine <$> (rangeForAnnotated mismatchSite),
349
+ (,Type2 ) <$> rangeForAnnotated expectedLeaf
350
+ ],
351
+ fromOverHere'
352
+ src
353
+ [styleAnnotated Type1 foundLeaf]
354
+ [styleAnnotated Type2 expectedLeaf],
355
+ unitHint,
356
+ intLiteralSyntaxTip mismatchSite expectedType,
357
+ debugNoteLoc
358
+ . mconcat
359
+ $ [ " \n loc debug:" ,
360
+ " \n mismatchSite: " ,
361
+ annotatedToEnglish mismatchSite,
362
+ " \n foundType: " ,
363
+ annotatedToEnglish foundType,
364
+ " \n foundLeaf: " ,
365
+ annotatedToEnglish foundLeaf,
366
+ " \n expectedType: " ,
367
+ annotatedToEnglish expectedType,
368
+ " \n expectedLeaf: " ,
369
+ annotatedToEnglish expectedLeaf,
370
+ " \n "
371
+ ],
372
+ debugSummary note
373
+ ]
374
+ where
375
+ unitHintMsg =
376
+ " \n Hint: Actions within a block must have type "
377
+ <> style Type2 (renderType' env expectedLeaf)
378
+ <> " .\n "
379
+ <> " Use "
380
+ <> style Type1 " _ = <expr>"
381
+ <> " to ignore a result."
382
+ unitHint = if giveUnitHint then unitHintMsg else " "
383
+ giveUnitHint = case expectedType of
384
+ Type. Ref' u | u == unitRef -> case mismatchSite of
385
+ Term. Let1Named' v _ _ -> Var. isAction v
386
+ _ -> False
387
+ _ -> False
331
388
NotFunctionApplication {.. } ->
332
389
case Type. arity ft of
333
390
0 ->
0 commit comments