Correctly report source compilation diagnostics

This commit is contained in:
Jarrod Doyle 2024-03-08 17:40:07 +00:00
parent 44ddda9736
commit 6f8c99ed4c
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 3 additions and 3 deletions

View File

@ -23,17 +23,17 @@ impl Runtime {
let mut diagnostics = Diagnostics::new(); let mut diagnostics = Diagnostics::new();
let (mut sources, source_paths) = Self::get_sources(source_dir)?; let (mut sources, source_paths) = Self::get_sources(source_dir)?;
let unit = rune::prepare(&mut sources) let result = rune::prepare(&mut sources)
.with_context(&context) .with_context(&context)
.with_diagnostics(&mut diagnostics) .with_diagnostics(&mut diagnostics)
.build()?; .build();
if !diagnostics.is_empty() { if !diagnostics.is_empty() {
let mut writer = StandardStream::stderr(ColorChoice::Always); let mut writer = StandardStream::stderr(ColorChoice::Always);
diagnostics.emit(&mut writer, &sources)?; diagnostics.emit(&mut writer, &sources)?;
} }
let vm = Vm::new(runtime, Arc::new(unit)); let vm = Vm::new(runtime, Arc::new(result?));
Ok(Self { Ok(Self {
vm, vm,