Skip to content

fix(codegen): anchor debug locations to their own statement - #1900

Open
ghaith wants to merge 1 commit into
masterfrom
fix/PRG-4711-branch-body-locations
Open

fix(codegen): anchor debug locations to their own statement#1900
ghaith wants to merge 1 commit into
masterfrom
fix/PRG-4711-branch-body-locations

Conversation

@ghaith

@ghaith ghaith commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

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 --all and cargo clippy --workspace -- -Dwarnings are 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 REPEAT and a FOR entry 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.

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>
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown

Build Artifacts

🐧 Linux

Artifact Link Size
deb-x86_64 Download 40.8 MB
schema Download 0.0 MB
stdlib Download 39.4 MB
plc-x86_64 Download 43.5 MB
deb-aarch64 Download 31.9 MB
plc-aarch64 Download 43.4 MB

From workflow run

🪟 Windows

Artifact Link Size
stdlib.lib Download 5.3 MB
stdlib.dll Download 0.3 MB
plc.exe Download 38.3 MB

From workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants