on master help sign in
Fill in some TODOs in type error messages
e60b6d1Evan Czaplicki
src/Reporting/Error/Type.hs+57−47
@@ -472,48 +472,48 @@ problemToHint problem =
472
472
473 T.BadFlexSuper super _ tipe ->
473 T.BadFlexSuper super _ tipe ->
474 case tipe of
474 case tipe of
475− T.Lambda _ _ _ -> badFlexSuper super
475+ T.Lambda _ _ _ -> badFlexSuper super
476− T.Infinite -> []
476+ T.Infinite -> []
477− T.Error -> []
477+ T.Error -> []
478− T.FlexVar _ -> []
478+ T.FlexVar _ -> []
479− T.FlexSuper s _ -> badDoubleFlexSuper super s
479+ T.FlexSuper s _ -> badDoubleFlexSuper super s
480− T.RigidVar _y -> error "TODO"
480+ T.RigidVar y -> badRigidVar y (toASuperThing super)
481− T.RigidSuper _s _y -> error "TODO"
481+ T.RigidSuper s _ -> error "TODO"
482− T.Type _ _ _ -> badFlexSuper super
482+ T.Type _ _ _ -> badFlexSuper super
483− T.Record _ _ -> badFlexSuper super
483+ T.Record _ _ -> badFlexSuper super
484− T.Unit -> badFlexSuper super
484+ T.Unit -> badFlexSuper super
485− T.Tuple _ _ _ -> badFlexSuper super
485+ T.Tuple _ _ _ -> badFlexSuper super
486− T.Alias _ _ _ _ -> badFlexSuper super
486+ T.Alias _ _ _ _ -> badFlexSuper super
487
487
488 T.BadRigidVar x tipe ->
488 T.BadRigidVar x tipe ->
489 case tipe of
489 case tipe of
490− T.Lambda _ _ _ -> badRigidVar x "a function"
490+ T.Lambda _ _ _ -> badRigidVar x "a function"
491− T.Infinite -> []
491+ T.Infinite -> []
492− T.Error -> []
492+ T.Error -> []
493− T.FlexVar _ -> []
493+ T.FlexVar _ -> []
494− T.FlexSuper _s _y -> error "TODO"
494+ T.FlexSuper s _ -> badRigidVar x (toASuperThing s)
495− T.RigidVar y -> badDoubleRigid x y
495+ T.RigidVar y -> badDoubleRigid x y
496− T.RigidSuper _ y -> badDoubleRigid x y
496+ T.RigidSuper _ y -> badDoubleRigid x y
497− T.Type _ name _ -> badRigidVar x ("a `" ++ N.toString name ++ "` value")
497+ T.Type _ n _ -> badRigidVar x ("a `" ++ N.toString n ++ "` value")
498− T.Record _ _ -> badRigidVar x "a record"
498+ T.Record _ _ -> badRigidVar x "a record"
499− T.Unit -> badRigidVar x "a unit value"
499+ T.Unit -> badRigidVar x "a unit value"
500− T.Tuple _ _ _ -> badRigidVar x "a tuple"
500+ T.Tuple _ _ _ -> badRigidVar x "a tuple"
501− T.Alias _ name _ _ -> badRigidVar x ("a `" ++ N.toString name ++ "` value")
501+ T.Alias _ n _ _ -> badRigidVar x ("a `" ++ N.toString n ++ "` value")
502
502
503 T.BadRigidSuper super x tipe ->
503 T.BadRigidSuper super x tipe ->
504 case tipe of
504 case tipe of
505− T.Lambda _ _ _ -> badRigidSuper super "a function"
505+ T.Lambda _ _ _ -> badRigidSuper super "a function"
506− T.Infinite -> []
506+ T.Infinite -> []
507− T.Error -> []
507+ T.Error -> []
508− T.FlexVar _ -> []
508+ T.FlexVar _ -> []
509− T.FlexSuper _s _y -> error "TODO"
509+ T.FlexSuper s _ -> error "TODO"
510− T.RigidVar y -> badDoubleRigid x y
510+ T.RigidVar y -> badDoubleRigid x y
511− T.RigidSuper _ y -> badDoubleRigid x y
511+ T.RigidSuper _ y -> badDoubleRigid x y
512− T.Type _ name _ -> badRigidSuper super ("a `" ++ N.toString name ++ "` value")
512+ T.Type _ n _ -> badRigidSuper super ("a `" ++ N.toString n ++ "` value")
513− T.Record _ _ -> badRigidSuper super "a record"
513+ T.Record _ _ -> badRigidSuper super "a record"
514− T.Unit -> badRigidSuper super "a unit value"
514+ T.Unit -> badRigidSuper super "a unit value"
515− T.Tuple _ _ _ -> badRigidSuper super "a tuple"
515+ T.Tuple _ _ _ -> badRigidSuper super "a tuple"
516− T.Alias _ name _ _ -> badRigidSuper super ("a `" ++ N.toString name ++ "` value")
516+ T.Alias _ n _ _ -> badRigidSuper super ("a `" ++ N.toString n ++ "` value")
517
517
518
518
519badFlexSuper :: T.Super -> [H.Doc]
519badFlexSuper :: T.Super -> [H.Doc]
@@ -538,19 +538,29 @@ badRigidVar name aThing =
538 ]
538 ]
539
539
540
540
541+toASuperThing :: T.Super -> String
542+toASuperThing super =
543+ case super of
544+ T.Number -> "a `number` value"
545+ T.Comparable -> "a `comparable` value"
546+ T.CompAppend -> "a `compappend` value"
547+ T.Appendable -> "an `appendable` value"
548+
549+
541badDoubleFlexSuper :: T.Super -> T.Super -> [H.Doc]
550badDoubleFlexSuper :: T.Super -> T.Super -> [H.Doc]
542badDoubleFlexSuper s1 s2 =
551badDoubleFlexSuper s1 s2 =
543 let
552 let
544− whatever =
553+ likeThis super =
545− [ H.toSimpleHint $
554+ case super of
546− "There are no "
555+ T.Number -> "a number"
547− ]
556+ T.Comparable -> "comparable"
557+ T.CompAppend -> "a compappend"
558+ T.Appendable -> "appendable"
548 in
559 in
549− case s1 of
560+ [ H.toSimpleHint $
550− T.Number -> error "TODO" whatever s1 s2
561+ "There are no values in Elm that are both"
551− T.Comparable -> error "TODO" whatever s1 s2
562+ ++ likeThis s1 ++ " and " ++ likeThis s2 ++ "."
552− T.Appendable -> error "TODO" whatever s1 s2
563+ ]
553− T.CompAppend -> error "TODO" whatever s1 s2
554
564
555
565
556badRigidSuper :: T.Super -> String -> [H.Doc]
566badRigidSuper :: T.Super -> String -> [H.Doc]
@@ -564,8 +574,8 @@ badRigidSuper super aThing =
564 T.CompAppend -> ("compappend", "strings AND lists")
574 T.CompAppend -> ("compappend", "strings AND lists")
565 in
575 in
566 [ H.toSimpleHint $
576 [ H.toSimpleHint $
567− "The `" ++ superType ++ "` in your type annotation is saying that " ++
577+ "The `" ++ superType ++ "` in your type annotation is saying that "
568− manyThings ++ " can flow through, but your code is saying it specifically wants "
578+ ++ manyThings ++ " can flow through, but your code is saying it specifically wants "
569 ++ aThing ++ ". Maybe change your type annotation to\
579 ++ aThing ++ ". Maybe change your type annotation to\
570 \ be more specific? Maybe change the code to be more general?"
580 \ be more specific? Maybe change the code to be more general?"
571 , H.reflowLink "Read" "type-annotations" "for more advice!"
581 , H.reflowLink "Read" "type-annotations" "for more advice!"