Skip to content

Keep shared read and format helpers out of source line tables - #804

Merged
ctate merged 1 commit into
mainfrom
ctate/keep-shared-read-b012e5
Oct 9, 2026
Merged

ctate merged 1 commit into
mainfrom
ctate/keep-shared-read-b012e5

Conversation

@ctate

@ctate ctate commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Fixes the macOS debug-variables.test.ts failure on main, where LLDB stopped at a breakpoint location in compiler helper code and then could not find the loop variable i.

Indexed reads that can miss lower through shared helpers (%arr.idxOr, %bytes.idxOr), and printing a value that can be undefined goes through a shared formatter (%util.fmtv). Each helper took the location of the read or print that first created it, so its body carried that line's debug locations. A breakpoint on that line then also resolved inside the helpers (three locations for console.log("loop", i, bytes[i])), where the user's variables are not in scope.

  • New helperLoc(loc) in ir/build.ts: a location without a source position, so the helper emits no debug info at all. Call sites keep the user's location, so a breakpoint on the line stops only at the read or print itself.
  • Used for the indexed-read helpers in array-values.ts and the union formatter in lower-inspect.ts.

Validation: in the dev-mode LLVM for the debug-variables corpus program, line 22 now has a single debug location (it had three), and the helpers have no !dbg subprogram. 816 focused typed-array, union, inspect and debug programs pass in both differential lanes, sanitized. Lowering, IR and debug-info unit tests pass (519), and lint and format are clean. The LLDB test itself runs only on macOS CI.

Indexed reads that can miss lower through shared helpers (`%arr.idxOr`,
`%bytes.idxOr`), and printing a value that can be undefined goes through a
shared formatter (`%util.fmtv`). Each helper took the location of the read
or print that first created it, so its body carried that line's debug
locations. A breakpoint on such a line then resolved to every helper as
well, and the debugger stopped inside helper code where the user's
variables are not in scope.

The helpers are compiler code, so they now get a location without a
source position (helperLoc). They emit no debug info, while each call
still carries the user's location, so a breakpoint on the line stops only
at the read or print itself.
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptc Ready Ready Preview, v0 Oct 9, 2026 7:51pm UTC

@ctate
ctate merged commit ecc664c into main Oct 9, 2026
74 of 77 checks passed

This branch was successfully deployed

1 active deployment
Preview — 860f9339 Deployed Oct 9, 2026 by vercel[bot]
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.

1 participant