From 2b4ad47c16dc0fb114be0fd03526ffb871aa1875 Mon Sep 17 00:00:00 2001 From: Linus Heckemann Date: Thu, 1 Jun 2023 21:21:23 +0200 Subject: fix(tvix/eval): emit only warnings on shadowed outputs Unfortunately, nixpkgs has at least one case[1] where the out environment variable is shadowed -- though it doesn't cause a problem, since it's shadowed with the correct value, odd as this may be! [1]: https://github.com/NixOS/nixpkgs/blob/c7c298471676ac1c7789ab3c424fbcebecaa6791/pkgs/development/python-modules/pybind11/default.nix#L19 Change-Id: Ibf6790d2484dc9cce8e424feeb5886664d498dc3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8696 Autosubmit: tazjin Reviewed-by: tazjin Tested-by: BuildkiteCI --- tvix/eval/src/vm/generators.rs | 2 +- tvix/eval/src/warnings.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tvix/eval') diff --git a/tvix/eval/src/vm/generators.rs b/tvix/eval/src/vm/generators.rs index f86683dff542..138600be194a 100644 --- a/tvix/eval/src/vm/generators.rs +++ b/tvix/eval/src/vm/generators.rs @@ -650,7 +650,7 @@ pub(crate) async fn emit_warning(co: &GenCo, warning: EvalWarning) { } /// Emit a runtime warning with the span of the current generator. -pub(crate) async fn emit_warning_kind(co: &GenCo, kind: WarningKind) { +pub async fn emit_warning_kind(co: &GenCo, kind: WarningKind) { match co.yield_(VMRequest::EmitWarningKind(kind)).await { VMResponse::Empty => {} msg => panic!( diff --git a/tvix/eval/src/warnings.rs b/tvix/eval/src/warnings.rs index aa567f302755..e007d9c34f2d 100644 --- a/tvix/eval/src/warnings.rs +++ b/tvix/eval/src/warnings.rs @@ -17,6 +17,7 @@ pub enum WarningKind { DeadCode, EmptyInherit, EmptyLet, + ShadowedOutput(String), /// Tvix internal warning for features triggered by users that are /// not actually implemented yet, but do not cause runtime failures. @@ -100,6 +101,11 @@ impl EvalWarning { WarningKind::EmptyLet => "this `let`-expression contains no bindings".to_string(), + WarningKind::ShadowedOutput(ref out) => format!( + "this derivation's environment shadows the output name {}", + out + ), + WarningKind::NotImplemented(what) => { format!("feature not yet implemented in tvix: {}", what) } @@ -120,6 +126,7 @@ impl EvalWarning { WarningKind::DeadCode => "W008", WarningKind::EmptyInherit => "W009", WarningKind::EmptyLet => "W010", + WarningKind::ShadowedOutput(_) => "W011", WarningKind::NotImplemented(_) => "W999", } -- cgit 1.4.1