on master help sign in
Assume all variables with the "Native." prefix exist and have type "a"
commit666d9f8ca3c916f1e700b54712068840aa521e04 authorEvan Czaplicki <info@elm-lang.org> dateThu 25 Jul 2013, 01:23 (13 years ago) parent2609f5d
1 file changed+9−2
compiler/Type/Solve.hs+9−2
compiler/Type/Solve.hs+9−2
@@ -7,6 +7,7 @@ import qualified Data.UnionFind.IO as UF
77import qualified Data.Map as Map
88import qualified Data.Traversable as Traversable
99import qualified Data.Maybe as Maybe
10+import qualified Data.List as List
1011import Type.Type
1112import Type.Unify
1213import qualified Type.Environment as Env
@@ -118,8 +119,14 @@ solve constraint =
118119
119120 CInstance name term -> do
120121 env <- TS.getEnv
121− let msg = "Could not find '" ++ name ++ "' when solving type constraints."
122− freshCopy <- TS.makeInstance (Map.findWithDefault (error msg) name env)
122+ freshCopy <-
123+ case Map.lookup name env of
124+ Just tipe -> TS.makeInstance tipe
125+ Nothing
126+ | List.isPrefixOf "Native." name -> liftIO flexibleVar
127+ | otherwise ->
128+ error ("Could not find '" ++ name ++ "' when solving type constraints.")
129+
123130 t <- TS.flatten term
124131 unify freshCopy t
125132