about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r--tvix/eval/src/compiler/mod.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 7868bced4653..440ac284c1a6 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -1114,21 +1114,17 @@ impl Compiler<'_, '_> {
             self.scope_mut().poison(global_ident, depth);
         }
 
-        let mut shadowed = false;
         for other in self.scope().locals.iter().rev() {
             if other.has_name(&name) && other.depth == depth {
-                shadowed = true;
+                self.emit_error(
+                    self.span_for(node),
+                    ErrorKind::VariableAlreadyDefined(other.span),
+                );
+
                 break;
             }
         }
 
-        if shadowed {
-            self.emit_error(
-                self.span_for(node),
-                ErrorKind::VariableAlreadyDefined(name.clone()),
-            );
-        }
-
         let span = self.span_for(node);
         self.scope_mut().declare_local(name, span)
     }
@@ -1264,7 +1260,7 @@ impl Compiler<'_, '_> {
         N: AstNode<Language = rnix::NixLanguage>,
     {
         Error {
-            kind: ErrorKind::DynamicKeyInLet(node.syntax().clone()),
+            kind: ErrorKind::DynamicKeyInLet,
             span: self.span_for(node),
         }
     }