Track the region for record access names
Will be used to make error messages about them more precise!
commit2b0bc09efc156925dfc2a54acac0d433807ddcd1
authorEvan Czaplicki <evancz@users.noreply.github.com>
dateWed 25 Apr 2018, 02:27 (9 years ago)
parentde745e9
compiler/src/AST/Canonical.hs+1−1
@@ -100,7 +100,7 @@ data Expr_
100100 | LetDestruct Pattern Expr Expr
101101 | Case Expr [CaseBranch]
102102 | Accessor N.Name
103− | Access Expr N.Name
103+ | Access Expr (A.Located N.Name)
104104 | Update N.Name Expr (Map.Map N.Name FieldUpdate)
105105 | Record (Map.Map N.Name Expr)
106106 | Unit
compiler/src/AST/Source.hs+1−1
@@ -52,7 +52,7 @@ data Expr_
5252 | Let [A.Located Def] Expr
5353 | Case Expr [(Pattern, Expr)]
5454 | Accessor N.Name
55− | Access Expr N.Name
55+ | Access Expr (A.Located N.Name)
5656 | Update (A.Located N.Name) [(A.Located N.Name, Expr)]
5757 | Record [(A.Located N.Name, Expr)]
5858 | Unit
compiler/src/AST/Valid.hs+1−1
@@ -51,7 +51,7 @@ data Expr_
5151 | Let [Def] Expr
5252 | Case Expr [(Src.Pattern, Expr)]
5353 | Accessor N.Name
54− | Access Expr N.Name
54+ | Access Expr (A.Located N.Name)
5555 | Update (A.Located N.Name) [(A.Located N.Name, Expr)]
5656 | Record [(A.Located N.Name, Expr)]
5757 | Unit
compiler/src/Optimize/Expression.hs+1−1
@@ -146,7 +146,7 @@ optimize cycle (A.At region expression) =
146146 Can.Accessor field ->
147147 Names.registerField field (Opt.Accessor field)
148148
149− Can.Access record field ->
149+ Can.Access record (A.At _ field) ->
150150 do optRecord <- optimize cycle record
151151 Names.registerField field (Opt.Access optRecord field)
152152
compiler/src/Parse/Expression.hs+2−1
@@ -92,9 +92,10 @@ accessible :: R.Position -> Src.Expr -> Parser Src.Expr
9292accessible start expr =
9393 oneOf
9494 [ do Symbol.dot
95+ pos <- getPosition
9596 field <- Var.lower
9697 end <- getPosition
97− let newExpr = A.at start end (Src.Access expr field)
98+ let newExpr = A.at start end (Src.Access expr (A.at pos end field))
9899 accessible start newExpr
99100 , return expr
100101 ]