about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/scope.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-09-01T16·57+0300
committertazjin <tazjin@tvl.su>2022-09-07T20·04+0000
commit55d21a1389504d6d9872144077196bac9ee17feb (patch)
tree25e8a57afc217102e6dd7a75b4d3eed33403e961 /tvix/eval/src/compiler/scope.rs
parent80333009008b8a6ee644b7504b65f4c337418a3b (diff)
refactor(tvix/eval): store spans instead of nodes in Warning/Error r/4737
Another step towards being able to report accurate errors. The codemap
spans contain strictly more accessible information, as they now retain
information about which input file something came from.

This required some shuffling around in the compiler to thread all the
right information to the right places.

Change-Id: I18ccfb20f07b0c33e1c4f51ca00cd09f7b2d19c6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6404
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/compiler/scope.rs')
-rw-r--r--tvix/eval/src/compiler/scope.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/tvix/eval/src/compiler/scope.rs b/tvix/eval/src/compiler/scope.rs
index 7614fc2b2b11..b1ad4bfcd2b7 100644
--- a/tvix/eval/src/compiler/scope.rs
+++ b/tvix/eval/src/compiler/scope.rs
@@ -27,8 +27,8 @@ pub struct Local {
     // of `let`-expressions.
     pub name: String,
 
-    // Syntax node at which this local was declared.
-    pub node: Option<rnix::SyntaxNode>,
+    // Source span at which this local was declared.
+    pub span: codemap::Span,
 
     // Scope depth of this local.
     pub depth: usize,
@@ -203,14 +203,14 @@ impl Scope {
     /// Declare a local variable that occupies a stack slot and should
     /// be accounted for, but is not directly accessible by users
     /// (e.g. attribute sets used for `with`).
-    pub fn declare_phantom(&mut self) -> LocalIdx {
+    pub fn declare_phantom(&mut self, span: codemap::Span) -> LocalIdx {
         let idx = self.locals.len();
         self.locals.push(Local {
+            span,
             depth: self.scope_depth,
             initialised: true,
             needs_finaliser: false,
             name: "".into(),
-            node: None,
             phantom: true,
             used: true,
         });
@@ -219,14 +219,14 @@ impl Scope {
     }
 
     /// Declare an uninitialised local variable.
-    pub fn declare_local(&mut self, name: String, node: rnix::SyntaxNode) -> LocalIdx {
+    pub fn declare_local(&mut self, name: String, span: codemap::Span) -> LocalIdx {
         let idx = self.locals.len();
         self.locals.push(Local {
             name,
+            span,
             depth: self.scope_depth,
             initialised: false,
             needs_finaliser: false,
-            node: Some(node),
             phantom: false,
             used: false,
         });