feat(tvix/eval): add mechanism for emitting warnings from compiler

These can be used predominantly to emit warnings about things that the
compiler can infer, such as deprecated language features.

Change-Id: I3649c625459d7f3f95cdf42d5c651d23d66569ec
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6174
Reviewed-by: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-08-12 17:07:32 +03:00 committed by tazjin
parent 5512108ca7
commit 7e77972d71
4 changed files with 39 additions and 5 deletions

View file

@ -14,8 +14,16 @@ pub fn interpret(code: &str) -> EvalResult<Value> {
println!("{}", ast.root().dump());
}
let code = crate::compiler::compile(ast)?;
println!("code: {:?}", code);
let result = crate::compiler::compile(ast)?;
println!("code: {:?}", result.chunk);
crate::vm::run_chunk(code)
for warning in result.warnings {
eprintln!(
"warning: {:?} at {:?}",
warning.kind,
warning.node.text_range().start()
)
}
crate::vm::run_chunk(result.chunk)
}