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:
parent
4b9178fa2a
commit
07e03498f2
4 changed files with 57 additions and 8 deletions
|
|
@ -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,
|
||||
"{}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue