fix(codegen): anchor debug locations to their own statement - #1900
Open
ghaith wants to merge 1 commit into
Open
Conversation
Problem: Instructions that carry no debug location of their own, such as the argument stores of a call, were attributed to the statement generated before them. A branch body then shared its line with the enclosing condition or end keyword, leaving the body without a line-table row of its own, so a debugger could not place a breakpoint on it. Solution: Register a statement's location before generating it, so every statement's instructions start out attributed to that statement. Refs: PRG-4711 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Build Artifacts🐧 Linux
From workflow run 🪟 Windows
From workflow run |
volsa
approved these changes
Sep 1, 2026
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.
Problem: Instructions that carry no debug location of their own, such as the argument stores of a call, were attributed to the statement generated before them. A branch body then shared its line with the enclosing condition or end keyword, so it had no line-table row and a debugger could not place a breakpoint on it.
Solution: Register a statement's location before generating it, so every statement's instructions start out attributed to that statement. The existing per-arm registrations still refine this where they have a more precise location.
Refs: PRG-4711
Testing
cargo test --workspace, the lit suite,cargo fmt --allandcargo clippy --workspace -- -Dwarningsare clean. A new lit test asserts that a CASE and an IF body share their location with the call they contain, and that the location is the body's own line; it fails without the change.Five snapshots moved, all in the same direction: a CASE selector load, a
REPEATand aFORentry branch that had carried line 0, the receiver of a method call, and a statement that emits no instructions no longer leaking its location onto the next statement.