git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1467 from purescript/862
a4888d2Phil Freeman
examples/failing/Arrays.purs+1−1
@@ -1,4 +1,4 @@
1−-- @shouldFailWith ExprDoesNotHaveType
1+-- @shouldFailWith TypesDoNotUnify
2module Main where
2module Main where
3
3
4import Prelude
4import Prelude
examples/failing/MultipleErrors.purs+2−2
@@ -1,5 +1,5 @@
1−-- @shouldFailWith ExprDoesNotHaveType
1+-- @shouldFailWith TypesDoNotUnify
2−-- @shouldFailWith ExprDoesNotHaveType
2+-- @shouldFailWith TypesDoNotUnify
3module MultipleErrors where
3module MultipleErrors where
4
4
5import Prelude
5import Prelude
examples/failing/Rank2Types.purs+1−1
@@ -1,4 +1,4 @@
1−-- @shouldFailWith ExprDoesNotHaveType
1+-- @shouldFailWith TypesDoNotUnify
2module Main where
2module Main where
3
3
4import Prelude
4import Prelude
examples/failing/TypeError.purs+1−1
@@ -1,4 +1,4 @@
1−-- @shouldFailWith ExprDoesNotHaveType
1+-- @shouldFailWith TypesDoNotUnify
2module Main where
2module Main where
3
3
4import Prelude
4import Prelude
examples/passing/862.pursnew file+8
@@ -0,0 +1,8 @@
1+module Main where
2+
3+import Prelude
4+import Control.Monad.Eff.Console
5+
6+id' = (\x -> x) <$> \y -> y
7+
8+main = log (id' "Done")
src/Language/PureScript/TypeChecker/Types.hs+6−1
@@ -592,7 +592,12 @@ check' val kt@(KindedType ty kind) = do
592 return $ TypedValue True val' kt
592 return $ TypedValue True val' kt
593check' (PositionedValue pos _ val) ty =
593check' (PositionedValue pos _ val) ty =
594 warnAndRethrowWithPosition pos $ check' val ty
594 warnAndRethrowWithPosition pos $ check' val ty
595+check' val ty = do
596+ TypedValue _ val' ty' <- infer val
597+ mt <- subsumes (Just val') ty' ty
598+ case mt of
595−check' val ty = throwError . errorMessage $ ExprDoesNotHaveType val ty
599+ Nothing -> throwError . errorMessage $ SubsumptionCheckFailed
600+ Just v' -> return $ TypedValue True v' ty
596
601
597containsTypeSynonyms :: Type -> Bool
602containsTypeSynonyms :: Type -> Bool
598containsTypeSynonyms = everythingOnTypes (||) go where
603containsTypeSynonyms = everythingOnTypes (||) go where