Skip to content

Fix block comments ending in **/ - #445

Open
HoneyPaptan wants to merge 1 commit into
antonmedv:masterfrom
HoneyPaptan:fix-block-comment-end
Open

HoneyPaptan wants to merge 1 commit into
antonmedv:masterfrom
HoneyPaptan:fix-block-comment-end

Conversation

@HoneyPaptan

Copy link
Copy Markdown

A block comment whose closing */ is preceded by another *, such as /** doc **/ or /***/, is never seen as closed. After a * that is not followed by /, the scanner steps past that next character, so the * of **/ is skipped and the comment runs to the end of input:

$ printf '{"a": 1 /* note **/}\n' | fx .
Unexpected end of input in comment on line 2.

Both the Go parser and the npm version now check a * again when the previous * did not close the comment.

Verified on Go 1.27.1 / Linux amd64:

  • The new jsonx cases (/** comment **/, /***/, {"a":1 /* comment **/}) fail before the change with "Unexpected end of input in comment" and pass after it. Unclosed comments such as /*/ "test" and /* test * still fail.
  • The new npm test fails before the change (empty output) and passes after it.
  • go test ./..., go vet and cd npm && node test.js pass; gofmt -l is clean.

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