Skip to content

Report the correct column for an undefined global reference#1585

Merged
saghul merged 1 commit into
quickjs-ng:masterfrom
littledivy:fix/global-ref-column
Jul 18, 2026
Merged

Report the correct column for an undefined global reference#1585
saghul merged 1 commit into
quickjs-ng:masterfrom
littledivy:fix/global-ref-column

Conversation

@littledivy

Copy link
Copy Markdown
Contributor

A ReferenceError for an undefined global pointed at column 1 (or the start of the enclosing function) instead of the column of the reference itself, because the variable-load opcode was emitted with the surrounding source position.

This emits the identifier's own line and column.

source before after
missingGlobal (col 4) 1:3 1:4
let a=1; alsoMissing (col 10) 1:9 1:10
function f(){ return missingGlobal; } f (1:1) f (1:22)

Disclaimer: This is an AI-assisted patch from the v8x project.

A ReferenceError for an undefined global pointed at column 1 (or the start
of the enclosing function) rather than the column of the reference itself,
because the OP_get_var_undef opcode was emitted with the surrounding source
position.

Emit the identifier's own line and column so e.g. `function f(){ return
missingGlobal; }` points at `missingGlobal` instead of the function.
@littledivy
littledivy force-pushed the fix/global-ref-column branch from e337752 to fa3d26e Compare July 17, 2026 18:29
@saghul
saghul merged commit d90ab51 into quickjs-ng:master Jul 18, 2026
128 checks passed
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