on master help sign in
Localize types from the current module as well
76a0954Evan Czaplicki
compiler/src/Compile.hs+7−3
@@ -89,12 +89,16 @@ compile flag pkg importDict interfaces source =
89runTypeInference :: [Src.Import] -> Can.Module -> Result i (Map.Map N.Name Can.Annotation)
89runTypeInference :: [Src.Import] -> Can.Module -> Result i (Map.Map N.Name Can.Annotation)
90runTypeInference imports canonical =
90runTypeInference imports canonical =
91 case unsafePerformIO (Type.run =<< Type.constrain canonical) of
91 case unsafePerformIO (Type.run =<< Type.constrain canonical) of
92− Left errors ->
93− Result.throw (Error.Type (L.fromImports imports) errors)
94−
95 Right annotations ->
92 Right annotations ->
96 Result.ok annotations
93 Result.ok annotations
97
94
95+ Left errors ->
96+ let
97+ localizer =
98+ L.fromImports (ModuleName._module (Can._name canonical)) imports
99+ in
100+ Result.throw (Error.Type localizer errors)
101+
98
102
99
103
100-- EXHAUSTIVENESS CHECK
104-- EXHAUSTIVENESS CHECK
compiler/src/Reporting/Render/Type/Localizer.hs+4−4
@@ -5,7 +5,6 @@ module Reporting.Render.Type.Localizer
5 , toDoc
5 , toDoc
6 , empty
6 , empty
7 , fromImports
7 , fromImports
8−
9 )
8 )
10 where
9 where
11
10
@@ -71,9 +70,10 @@ toDoc (Localizer localizer) home name =
71-- MAKE
70-- MAKE
72
71
73
72
74−fromImports :: [Src.Import] -> Localizer
73+fromImports :: N.Name -> [Src.Import] -> Localizer
75−fromImports imports =
74+fromImports self imports =
76− Localizer $ Map.fromList (map toPair imports)
75+ Localizer $ Map.fromList $
76+ (self, Import Nothing All) : map toPair imports
77
77
78
78
79toPair :: Src.Import -> (N.Name, Import)
79toPair :: Src.Import -> (N.Name, Import)