feat(tvix/eval): add method for emitting runtime warnings

This lets the VM emit warnings when it encounters situations that
should only be warned about at runtime.

For starters, this is used to pass through compilation warnings that
come up when `import` is used.

Change-Id: I0c4bc8c534d699999887c430d93629fadfa662c4
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6868
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2022-10-05 17:01:07 +03:00 committed by tazjin
parent 4b9178fa2a
commit 07e03498f2
4 changed files with 57 additions and 8 deletions

View file

@ -51,7 +51,7 @@ pub fn builtins_import(
Builtin::new(
"import",
&[true],
move |mut args: Vec<Value>, _: &mut VM| {
move |mut args: Vec<Value>, vm: &mut VM| {
let path = match args.pop().unwrap() {
Value::Path(path) => path,
Value::String(_) => {
@ -102,9 +102,9 @@ pub fn builtins_import(
});
}
// TODO: deal with runtime *warnings* (most likely through an
// emit_warning function on the VM that might return it together with
// the result)
for warning in result.warnings {
vm.push_warning(warning);
}
// Compilation succeeded, we can construct a thunk from whatever it spat
// out and return that.