diff options
author | Vincent Ambo <mail@tazj.in> | 2023-02-13T07·54+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-02-13T16·21+0000 |
commit | c98c5399b9ce7729a48e5ab5a1e389f31917aeb7 (patch) | |
tree | a48f57f850d9dfcca66fd27b7d01559595b22443 /tvix | |
parent | 91a366af465aad00141df82200530ccf5da11339 (diff) |
fix(tvix/eval): skip runtime completely on compiler errors r/5848
This branch was missing, and an assumption elsewhere just executed the returned (broken) bytecode. This fixes b/253. Change-Id: I015023ba921bc08ea03882167f1f560feca25e50 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8090 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/eval/src/lib.rs | 6 | ||||
-rw-r--r-- | tvix/eval/src/tests/one_offs.rs | 12 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tvix/eval/src/lib.rs b/tvix/eval/src/lib.rs index f903a078ff3b..44fe8af2ccc5 100644 --- a/tvix/eval/src/lib.rs +++ b/tvix/eval/src/lib.rs @@ -317,6 +317,12 @@ fn parse_compile_internal( result.warnings = compiler_result.warnings; result.errors.extend(compiler_result.errors); + // Short-circuit if errors exist at this point (do not pass broken + // bytecode to the runtime). + if !result.errors.is_empty() { + return None; + } + // Return the lambda (for execution) and the globals map (to // ensure the invariant that the globals outlive the runtime). Some((compiler_result.lambda, compiler_result.globals)) diff --git a/tvix/eval/src/tests/one_offs.rs b/tvix/eval/src/tests/one_offs.rs index 13b87267a987..23bc9465d6bb 100644 --- a/tvix/eval/src/tests/one_offs.rs +++ b/tvix/eval/src/tests/one_offs.rs @@ -22,3 +22,15 @@ fn test_source_builtin() { value, ); } + +#[test] +fn skip_broken_bytecode() { + let result = Evaluation::new(/* code = */ "x", None).evaluate(); + + assert_eq!(result.errors.len(), 1); + + assert!(matches!( + result.errors[0].kind, + ErrorKind::UnknownStaticVariable + )); +} |