diff options
author | Vincent Ambo <mail@tazj.in> | 2022-10-05T14·01+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-10-07T14·24+0000 |
commit | 07e03498f26afbf647102d656c90d447f8586820 (patch) | |
tree | 0f891cb5f2601e12bbbe89d10961f4f9b2d16fc1 /corp/tvixbolt/src | |
parent | 4b9178fa2ae4cab718225f6136791df1d11814ee (diff) |
feat(tvix/eval): add method for emitting runtime warnings r/5049
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
Diffstat (limited to 'corp/tvixbolt/src')
-rw-r--r-- | corp/tvixbolt/src/main.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/corp/tvixbolt/src/main.rs b/corp/tvixbolt/src/main.rs index f81ae070a2ce..8099a5238d02 100644 --- a/corp/tvixbolt/src/main.rs +++ b/corp/tvixbolt/src/main.rs @@ -292,7 +292,18 @@ fn eval(trace: bool, code: &str) -> Output { }; match result { - Ok(value) => writeln!(&mut out.output, "{}", value).unwrap(), + Ok(result) => { + for warning in result.warnings { + writeln!( + &mut out.warnings, + "{}\n", + warning.fancy_format_str(&source).trim(), + ) + .unwrap(); + } + + writeln!(&mut out.output, "{}", result.value).unwrap() + } Err(err) => writeln!( &mut out.runtime_errors, "{}", |