feat(tvix/eval): allow ignoring locals by prefixing with _
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>
This commit is contained in:
parent
a5e22c532b
commit
f6de4434c3
1 changed files with 2 additions and 1 deletions
|
|
@ -884,10 +884,11 @@ impl Compiler {
|
||||||
if let Some(Local {
|
if let Some(Local {
|
||||||
node: Some(node),
|
node: Some(node),
|
||||||
used,
|
used,
|
||||||
|
name,
|
||||||
..
|
..
|
||||||
}) = self.scope_mut().locals.pop()
|
}) = self.scope_mut().locals.pop()
|
||||||
{
|
{
|
||||||
if !used {
|
if !used && !name.starts_with('_') {
|
||||||
self.emit_warning(node, WarningKind::UnusedBinding);
|
self.emit_warning(node, WarningKind::UnusedBinding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue