diff options
Diffstat (limited to 'tvix/eval')
-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 + )); +} |