From 07fcaf034b17df80de2f37de008562209a76987c Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 24 Aug 2022 16:31:28 +0300 Subject: feat(tvix/eval): emit warnings when globals are being shadowed Change-Id: I7dae6978c2a4548382d7fa059b20ccdf35d2cf7f Reviewed-on: https://cl.tvl.fyi/c/depot/+/6257 Tested-by: BuildkiteCI Reviewed-by: sterni --- tvix/eval/src/compiler.rs | 1 + tvix/eval/src/warnings.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'tvix') diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs index cb97b61c989e..a2ab6273c102 100644 --- a/tvix/eval/src/compiler.rs +++ b/tvix/eval/src/compiler.rs @@ -900,6 +900,7 @@ impl Compiler { }; if let Some(global_ident) = key { + self.emit_warning(node.clone(), WarningKind::ShadowedGlobal(global_ident)); self.scope_mut().poison(global_ident, depth); } diff --git a/tvix/eval/src/warnings.rs b/tvix/eval/src/warnings.rs index 20aa9677466e..5bc8ed971aea 100644 --- a/tvix/eval/src/warnings.rs +++ b/tvix/eval/src/warnings.rs @@ -6,6 +6,7 @@ pub enum WarningKind { DeprecatedLiteralURL, UselessInherit, UnusedBinding, + ShadowedGlobal(&'static str), } #[derive(Debug)] -- cgit 1.4.1