on master help sign in
Properly add regions to port errors
commit42dcc29891383a5cee9516251930b1a067d87762 authorEvan Czaplicki <info@elm-lang.org> dateSat 9 May 2015, 10:54 (11 years ago) parentd5da02e
2 files changed+20−16
src/Canonicalize.hs+2−2 src/Canonicalize/Port.hs+18−14
src/Canonicalize.hs+2−2
@@ -277,7 +277,7 @@ declaration env (A.A region decl) =
277277 D.In name tipe ->
278278 canonicalize Canonicalize.tipe "port" name env tipe
279279 `Result.andThen` \canonicalType ->
280− D.Port <$> Port.check name Nothing canonicalType
280+ D.Port <$> Port.check region name Nothing canonicalType
281281
282282 D.Out name expr tipe ->
283283 let exprTypeResult =
@@ -287,7 +287,7 @@ declaration env (A.A region decl) =
287287 in
288288 exprTypeResult
289289 `Result.andThen` \(expr', tipe') ->
290− D.Port <$> Port.check name (Just expr') tipe'
290+ D.Port <$> Port.check region name (Just expr') tipe'
291291
292292 D.Fixity assoc prec op ->
293293 Result.ok (D.Fixity assoc prec op)
src/Canonicalize/Port.hs+18−14
@@ -10,30 +10,33 @@ import qualified AST.Type as T
1010import qualified AST.Variable as Var
1111import qualified Reporting.Annotation as A
1212import qualified Reporting.Error.Canonicalize as Error
13+import qualified Reporting.Region as R
1314import qualified Canonicalize.Result as Result
1415
1516
1617-- CHECK FOR PORT
1718
1819check
19− :: String
20+ :: R.Region
21+ -> String
2022 -> Maybe Canonical.Expr
2123 -> T.Canonical
2224 -> Result.ResultErr D.CanonicalPort
23−check name maybeExpr rootType =
24− D.CanonicalPort <$> checkHelp name maybeExpr rootType rootType
25+check region name maybeExpr rootType =
26+ D.CanonicalPort <$> checkHelp region name maybeExpr rootType rootType
2527
2628
2729checkHelp
28− :: String
30+ :: R.Region
31+ -> String
2932 -> Maybe Canonical.Expr
3033 -> T.Canonical
3134 -> T.Canonical
3235 -> Result.ResultErr (E.PortImpl Canonical.Expr T.Canonical)
33−checkHelp name maybeExpr rootType tipe =
36+checkHelp region name maybeExpr rootType tipe =
3437 case (maybeExpr, tipe) of
3538 (_, T.Aliased _ args t) ->
36− checkHelp name maybeExpr rootType (T.dealias args t)
39+ checkHelp region name maybeExpr rootType (T.dealias args t)
3740
3841 (Just expr, T.App (T.Type task) [ _x, _a ])
3942 | Var.isTask task ->
@@ -50,37 +53,38 @@ checkHelp name maybeExpr rootType tipe =
5053 case maybeExpr of
5154 Nothing ->
5255 const (E.In name (T.Signal rootType arg))
53− <$> validForeignType name True arg arg
56+ <$> validForeignType region name True arg arg
5457
5558 Just expr ->
5659 const (E.Out name expr (T.Signal rootType arg))
57− <$> validForeignType name False arg arg
60+ <$> validForeignType region name False arg arg
5861
5962 _ ->
6063 case maybeExpr of
6164 Nothing ->
6265 const (E.In name (T.Normal rootType))
63− <$> validForeignType name True rootType tipe
66+ <$> validForeignType region name True rootType tipe
6467
6568 Just expr ->
6669 const (E.Out name expr (T.Normal rootType))
67− <$> validForeignType name False rootType tipe
70+ <$> validForeignType region name False rootType tipe
6871
6972
7073-- CHECK INBOUND AND OUTBOUND TYPES
7174
7275validForeignType
73− :: String
76+ :: R.Region
77+ -> String
7478 -> Bool
7579 -> T.Canonical
7680 -> T.Canonical
7781 -> Result.ResultErr ()
78−validForeignType name isInbound rootType tipe =
82+validForeignType region name isInbound rootType tipe =
7983 let valid localType =
80− validForeignType name isInbound rootType localType
84+ validForeignType region name isInbound rootType localType
8185
8286 err problem =
83− Result.err $ A.A undefined $
87+ Result.err $ A.A region $
8488 Error.port name isInbound rootType tipe problem
8589 in
8690 case tipe of