Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances Modu runtime error reporting by attaching source spans to emitted bytecode instructions and rendering errors as Ariadne reports (optionally with “did you mean” help), then updates CLI/wasm frontends to print the richer error output.
Changes:
- Track
SimpleSpanper instruction inChunk, and plumb spans through the compiler emit path. - Use spans at runtime to format VM errors as Ariadne reports (including help suggestions for “closest match” cases).
- Adjust CLI/wasm error printing and extend debug disassembly output to include spans.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modu-wasm/src/lib.rs | Prints the new formatted runtime error output directly. |
| lang/test | Adds a stray file containing invalid Modu code (likely a manual repro). |
| lang/src/vm/vm.rs | Adds span-aware runtime error formatting via Ariadne and updates many runtime error sites to use it. |
| lang/src/vm/chunk.rs | Stores spans alongside instructions and updates emit to accept a span. |
| lang/src/compiler/compiler.rs | Passes AST spans into all bytecode emission sites; ensures if leaves a stack value when no else. |
| lang/src/cli/run.rs | Prints formatted runtime errors and shows spans in instruction debug output. |
| lang/src/cli/repl.rs | Prints formatted runtime errors in the REPL loop. |
| lang/examples/benchmark.modu | Adds a benchmark example program. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+904
to
+908
| fn runtime_error_with_help(&self, msg: String, help: String, span: SimpleSpan) -> String { | ||
| let src = std::fs::read_to_string(&self.source_path).unwrap_or_default(); | ||
| let filename = self.source_path.to_string_lossy().to_string(); | ||
|
|
||
| let mut buf: Vec<u8> = Vec::new(); |
Comment on lines
+886
to
+889
| fn runtime_error(&self, msg: String, span: SimpleSpan) -> String { | ||
| let src = std::fs::read_to_string(&self.source_path).unwrap_or_default(); | ||
| let filename = self.source_path.to_string_lossy().to_string(); | ||
|
|
| return Err(format!("undefined property '{}' on object.\nDid you maybe mean: '{}'?", name, closest.green())); | ||
| return Err(self.runtime_error_with_help( | ||
| format!("undefined property '{}' on object", name), | ||
| format!("did you maybe mean: '{}'?", closest.green()), |
| @@ -0,0 +1 @@ | |||
| "".replac(); No newline at end of file | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.