git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1583 from purescript/1577

Fix #1577, fix #1130

commit634790fd5fb440acb2cf5effd2e13c55c6e4ba6d authorPhil Freeman <paf31@cantab.net> dateWed 28 Oct 2015, 19:28 (11 years ago) parentacab6abc059120
2 files changed+10−5
src/Language/PureScript/Errors.hs+9−4 src/Language/PureScript/TypeChecker/Types.hs+1−1
src/Language/PureScript/Errors.hs+9−4
@@ -156,6 +156,7 @@ data ErrorMessageHint
156156 | ErrorCheckingAccessor Expr String
157157 | ErrorCheckingType Expr Type
158158 | ErrorCheckingKind Type
159+ | ErrorCheckingGuard
159160 | ErrorInferringType Expr
160161 | ErrorInApplication Expr Type Expr
161162 | ErrorInDataConstructor ProperName
@@ -530,15 +531,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
530531 , indent $ prettyPrintValue expr
531532 ]) binding
532533 renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
533− = paras [ line "Could not match expected type"
534+ = paras [ line "Could not match type"
534535 , indent $ typeAsBox t1
535− , line "with actual type"
536+ , line "with type"
536537 , indent $ typeAsBox t2
537538 ]
538539 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
539− paras [ line "Could not match expected kind"
540+ paras [ line "Could not match kind"
540541 , indent $ line $ prettyPrintKind k1
541− , line "with actual kind"
542+ , line "with kind"
542543 , indent $ line $ prettyPrintKind k2
543544 ]
544545 renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
@@ -730,6 +731,10 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
730731 , typeAsBox ty
731732 ]
732733 ]
734+ renderHint ErrorCheckingGuard detail =
735+ paras [ detail
736+ , line "while checking the type of a guard clause"
737+ ]
733738 renderHint (ErrorInferringType expr) detail =
734739 paras [ detail
735740 , Box.hsep 1 Box.top [ line "while inferring the type of"
src/Language/PureScript/TypeChecker/Types.hs+1−1
@@ -418,7 +418,7 @@ checkBinders nvals ret (CaseAlternative binders result : bs) = do
418418 case result of
419419 Left gs -> do
420420 gs' <- forM gs $ \(grd, val) -> do
421− grd' <- check grd tyBoolean
421+ grd' <- rethrow (addHint ErrorCheckingGuard) $ check grd tyBoolean
422422 val' <- TypedValue True <$> check val ret <*> pure ret
423423 return (grd', val')
424424 return $ Left gs'