@@ -73,6 +73,7 @@ import Unison.Util.AnnotatedText qualified as AT
73
73
import Unison.Util.ColorText (Color )
74
74
import Unison.Util.ColorText qualified as Color
75
75
import Unison.Util.Monoid (intercalateMap )
76
+ import Unison.Util.Monoid qualified as Monoid
76
77
import Unison.Util.Pretty (ColorText , Pretty )
77
78
import Unison.Util.Pretty qualified as Pr
78
79
import Unison.Util.Range (Range (.. ), startingLine )
@@ -274,6 +275,62 @@ renderTypeError e env src = case e of
274
275
" expression " ,
275
276
" need to have the same type."
276
277
]
278
+ FunctionUnderApplied {.. } ->
279
+ mconcat
280
+ [ Pr. lines
281
+ [ " I found a value of type: " <> style Type1 (renderType' env foundLeaf),
282
+ " where I expected to find: " <> style Type2 (renderType' env expectedLeaf),
283
+ " it looks like it might be a function application that's just missing these arguments:\n\n " ,
284
+ Monoid. intercalateMap " , " (style Type1 . renderType' env) needArgs
285
+ ],
286
+ " \n\n " ,
287
+ showSourceMaybes
288
+ src
289
+ [ -- these are overwriting the colored ranges for some reason?
290
+ -- (,Color.ForceShow) <$> rangeForAnnotated mismatchSite
291
+ -- , (,Color.ForceShow) <$> rangeForType foundType
292
+ -- , (,Color.ForceShow) <$> rangeForType expectedType
293
+ -- ,
294
+ (,Type1 ) . startingLine <$> (rangeForAnnotated mismatchSite),
295
+ (,Type2 ) <$> rangeForAnnotated expectedLeaf
296
+ ],
297
+ fromOverHere'
298
+ src
299
+ [styleAnnotated Type1 foundLeaf]
300
+ [styleAnnotated Type2 expectedLeaf],
301
+ unitHint,
302
+ intLiteralSyntaxTip mismatchSite expectedType,
303
+ debugNoteLoc
304
+ . mconcat
305
+ $ [ " \n loc debug:" ,
306
+ " \n mismatchSite: " ,
307
+ annotatedToEnglish mismatchSite,
308
+ " \n foundType: " ,
309
+ annotatedToEnglish foundType,
310
+ " \n foundLeaf: " ,
311
+ annotatedToEnglish foundLeaf,
312
+ " \n expectedType: " ,
313
+ annotatedToEnglish expectedType,
314
+ " \n expectedLeaf: " ,
315
+ annotatedToEnglish expectedLeaf,
316
+ " \n "
317
+ ],
318
+ debugSummary note
319
+ ]
320
+ where
321
+ unitHintMsg =
322
+ " \n Hint: Actions within a block must have type "
323
+ <> style Type2 (renderType' env expectedLeaf)
324
+ <> " .\n "
325
+ <> " Use "
326
+ <> style Type1 " _ = <expr>"
327
+ <> " to ignore a result."
328
+ unitHint = if giveUnitHint then unitHintMsg else " "
329
+ giveUnitHint = case expectedType of
330
+ Type. Ref' u | u == unitRef -> case mismatchSite of
331
+ Term. Let1Named' v _ _ -> Var. isAction v
332
+ _ -> False
333
+ _ -> False
277
334
NotFunctionApplication {.. } ->
278
335
case Type. arity ft of
279
336
0 ->
0 commit comments