diff options
author | Vincent Ambo <mail@tazj.in> | 2023-01-05T12·32+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-01-06T12·23+0000 |
commit | 4e98730f3809e92bc527dac7c7b7928cf311b0ca (patch) | |
tree | ff62841c5afca9a74148f459893ccc5cce41b7e5 /tvix | |
parent | e8dcdceb34585dfe82d826978f0f1cd8a673b474 (diff) |
feat(tvix/eval): warn about empty `inherit`s r/5604
Change-Id: I82bec6fe2210bcb88c46fd2fdf3e26bd613d1c1f Reviewed-on: https://cl.tvl.fyi/c/depot/+/7768 Reviewed-by: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/compiler/bindings.rs | 5 | ||||
-rw-r--r-- | tvix/eval/src/warnings.rs | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/compiler/bindings.rs b/tvix/eval/src/compiler/bindings.rs index 9d4269002369..93b3dc3cc666 100644 --- a/tvix/eval/src/compiler/bindings.rs +++ b/tvix/eval/src/compiler/bindings.rs @@ -321,6 +321,11 @@ impl Compiler<'_> { let mut inherit_froms: Vec<(ast::Expr, SmolStr, Span)> = vec![]; for inherit in node.inherits() { + if inherit.attrs().peekable().peek().is_none() { + self.emit_warning(&inherit, WarningKind::EmptyInherit); + continue; + } + match inherit.from() { // Within a `let` binding, inheriting from the outer scope is a // no-op *if* there are no dynamic bindings. diff --git a/tvix/eval/src/warnings.rs b/tvix/eval/src/warnings.rs index 9fb454e8147c..9ebf182f975d 100644 --- a/tvix/eval/src/warnings.rs +++ b/tvix/eval/src/warnings.rs @@ -15,6 +15,7 @@ pub enum WarningKind { InvalidNixPath(String), UselessBoolOperation(&'static str), DeadCode, + EmptyInherit, /// Tvix internal warning for features triggered by users that are /// not actually implemented yet, but do not cause runtime failures. @@ -95,6 +96,10 @@ impl EvalWarning { format!("this code will never be executed") } + WarningKind::EmptyInherit => { + format!("this `inherit` statement is empty") + } + WarningKind::NotImplemented(what) => { format!("feature not yet implemented in tvix: {}", what) } @@ -113,6 +118,7 @@ impl EvalWarning { WarningKind::InvalidNixPath(_) => "W006", WarningKind::UselessBoolOperation(_) => "W007", WarningKind::DeadCode => "W008", + WarningKind::EmptyInherit => "W009", WarningKind::NotImplemented(_) => "W999", } |