git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1454 from purescript/friendly-errors
5694421Phil Freeman
src/Language/PureScript/Errors.hs+19−13
@@ -443,9 +443,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
443 , indent . line $ path
443 , indent . line $ path
444 ]
444 ]
445 goSimple InvalidDoBind =
445 goSimple InvalidDoBind =
446− line "Bind statement cannot be the last statement in a do block"
446+ line "Bind statement cannot be the last statement in a do block. The last statement must be an expression."
447 goSimple InvalidDoLet =
447 goSimple InvalidDoLet =
448− line "Let statement cannot be the last statement in a do block"
448+ line "Let statement cannot be the last statement in a do block. The last statement must be an expression."
449 goSimple CannotReorderOperators =
449 goSimple CannotReorderOperators =
450 line "Unable to reorder operators"
450 line "Unable to reorder operators"
451 goSimple UnspecifiedSkolemScope =
451 goSimple UnspecifiedSkolemScope =
@@ -453,11 +453,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
453 goSimple OverlappingNamesInLet =
453 goSimple OverlappingNamesInLet =
454 line "Overlapping names in let binding."
454 line "Overlapping names in let binding."
455 goSimple (InfiniteType ty) =
455 goSimple (InfiniteType ty) =
456− paras [ line "Infinite type detected: "
456+ paras [ line "An infinite type was inferred for an expression: "
457 , indent $ line $ prettyPrintType ty
457 , indent $ line $ prettyPrintType ty
458 ]
458 ]
459 goSimple (InfiniteKind ki) =
459 goSimple (InfiniteKind ki) =
460− paras [ line "Infinite kind detected: "
460+ paras [ line "An infinite kind was inferred for a type: "
461 , indent $ line $ prettyPrintKind ki
461 , indent $ line $ prettyPrintKind ki
462 ]
462 ]
463 goSimple (MultipleFixities name) =
463 goSimple (MultipleFixities name) =
@@ -534,9 +534,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
534 goSimple (UndefinedTypeVariable name) =
534 goSimple (UndefinedTypeVariable name) =
535 line $ "Type variable " ++ show name ++ " is undefined"
535 line $ "Type variable " ++ show name ++ " is undefined"
536 goSimple (PartiallyAppliedSynonym name) =
536 goSimple (PartiallyAppliedSynonym name) =
537− line $ "Partially applied type synonym " ++ show name
537+ paras [ line $ "Partially applied type synonym " ++ show name
538+ , line "Type synonyms must be applied to all of their type arguments."
539+ ]
538 goSimple (EscapedSkolem binding) =
540 goSimple (EscapedSkolem binding) =
539− paras $ [ line "Rigid/skolem type variable has escaped." ]
541+ paras $ [ line "A type variable has escaped its scope." ]
540 <> foldMap (\expr -> [ line "Relevant expression: "
542 <> foldMap (\expr -> [ line "Relevant expression: "
541 , indent $ line $ prettyPrintValue expr
543 , indent $ line $ prettyPrintValue expr
542 ]) binding
544 ]) binding
@@ -610,7 +612,10 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
610 goSimple TypeSynonymInstance =
612 goSimple TypeSynonymInstance =
611 line "Type synonym instances are disallowed"
613 line "Type synonym instances are disallowed"
612 goSimple (OrphanInstance nm cnm ts) =
614 goSimple (OrphanInstance nm cnm ts) =
613− line $ "Instance " ++ show nm ++ " for " ++ show cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance"
615+ paras [ line $ "Instance " ++ show nm ++ " for " ++ show cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance."
616+ , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
617+ , line "Consider moving the instance, if possible, or using a newtype wrapper."
618+ ]
614 goSimple InvalidNewtype =
619 goSimple InvalidNewtype =
615 line "Newtypes must define a single constructor with a single argument"
620 line "Newtypes must define a single constructor with a single argument"
616 goSimple (InvalidInstanceHead ty) =
621 goSimple (InvalidInstanceHead ty) =
@@ -634,15 +639,16 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
634 goSimple (WildcardInferredType ty) =
639 goSimple (WildcardInferredType ty) =
635 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
640 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
636 goSimple (NotExhaustivePattern bs b) =
641 goSimple (NotExhaustivePattern bs b) =
637− indent $ paras $ [ line "Pattern could not be determined to cover all cases."
642+ paras $ [ line "A case expression could not be determined to cover all inputs."
638− , line $ "The definition has the following uncovered cases:\n"
643+ , line "The following additional cases are required to cover all inputs:\n"
639 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
644 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
640− ] ++ if not b then [line "..."] else []
645+ ] ++
646+ [ line "..." | not b ]
641 goSimple (OverlappingPattern bs b) =
647 goSimple (OverlappingPattern bs b) =
642− indent $ paras $ [ line "Redundant cases have been detected."
648+ paras $ [ line "A case expression contains unreachable cases:\n"
643− , line $ "The definition has the following redundant cases:\n"
644 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
649 , Box.hsep 1 Box.left (map (paras . map (line . prettyPrintBinderAtom)) (transpose bs))
645− ] ++ if not b then [line "..."] else []
650+ ] ++
651+ [ line "..." | not b ]
646 go (NotYetDefined names err) =
652 go (NotYetDefined names err) =
647 paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
653 paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
648 , indent $ go err
654 , indent $ go err