fix(tvix/eval): skip runtime completely on compiler errors
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>
This commit is contained in:
		
							parent
							
								
									91a366af46
								
							
						
					
					
						commit
						c98c5399b9
					
				
					 2 changed files with 18 additions and 0 deletions
				
			
		| 
						 | 
					@ -317,6 +317,12 @@ fn parse_compile_internal(
 | 
				
			||||||
    result.warnings = compiler_result.warnings;
 | 
					    result.warnings = compiler_result.warnings;
 | 
				
			||||||
    result.errors.extend(compiler_result.errors);
 | 
					    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
 | 
					    // Return the lambda (for execution) and the globals map (to
 | 
				
			||||||
    // ensure the invariant that the globals outlive the runtime).
 | 
					    // ensure the invariant that the globals outlive the runtime).
 | 
				
			||||||
    Some((compiler_result.lambda, compiler_result.globals))
 | 
					    Some((compiler_result.lambda, compiler_result.globals))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,3 +22,15 @@ fn test_source_builtin() {
 | 
				
			||||||
        value,
 | 
					        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
 | 
				
			||||||
 | 
					    ));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue