diff options
author | Vincent Ambo <mail@tazj.in> | 2022-08-27T21·04+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-09-06T07·45+0000 |
commit | f6de4434c3838431c8d5c0782f786c07ac46b212 (patch) | |
tree | 1cd6143d8947c38589a627aaf6cc75ff102f4da0 /tvix/eval/src/compiler/mod.rs | |
parent | a5e22c532b074cca80d15046e6aa109d9ca79a80 (diff) |
feat(tvix/eval): allow ignoring locals by prefixing with _ r/4656
This is a common idiom in both Nix and other languages when a local is declared without actually being used. Since Tvix warns for unused locals, having this available is useful and can be included in the final error message as a suggestion if an unused variable is intentional. Change-Id: Ia85f704ba183499a3bae657c58166e2e29f9bde5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6320 Tested-by: BuildkiteCI Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r-- | tvix/eval/src/compiler/mod.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs index bf5c55db2a0c..ffc7daf8e9b0 100644 --- a/tvix/eval/src/compiler/mod.rs +++ b/tvix/eval/src/compiler/mod.rs @@ -884,10 +884,11 @@ impl Compiler { if let Some(Local { node: Some(node), used, + name, .. }) = self.scope_mut().locals.pop() { - if !used { + if !used && !name.starts_with('_') { self.emit_warning(node, WarningKind::UnusedBinding); } } |