Report the correct column number for syntax errors#1582
Merged
Conversation
saghul
reviewed
Jul 17, 2026
| backtrace_flags = 0; | ||
| if (s->cur_func && s->cur_func->backtrace_barrier) | ||
| backtrace_flags = JS_BACKTRACE_FLAG_SINGLE_LEVEL; | ||
| // v82jsc patch: report the V8-compatible 1-based column of the offending |
Contributor
There was a problem hiding this comment.
Can you please reword this comment to be more on point? Also use /* */
Contributor
Author
There was a problem hiding this comment.
reworded to a single comment about deriving the column from the token offset.
A SyntaxError always reported column 1, regardless of where the offending token was. s->col_num is not advanced during normal token scanning (it stays 1 except on a few number-literal error paths), and the line number was taken from the parser state rather than the token, so both the column and occasionally the line were wrong. Report the token's line and compute the column as the 1-based offset of the token from the start of its source line, so e.g. `hocuspocus(` now points at 1:12 instead of 1:1.
littledivy
force-pushed
the
fix/parse-error-column
branch
from
July 17, 2026 13:06
6b8ba6f to
a342b99
Compare
saghul
approved these changes
Jul 17, 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.
A
SyntaxErroralways reported column 1, regardless of where the offending token was.s->col_numis not advanced during normal token scanning (it stays 1 except on a few number-literal error paths), and the line came from the parser state rather than the token, so the column (and occasionally the line) was wrong.The fix reports the token's line and computes the column as the 1-based offset of the token from the start of its source line.
hocuspocus(let x = ;1 + + ;let z = @on line 2Disclaimer: This is an AI-assisted patch from the v8x project.