You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Three boundary conditions in the comment flush machinery (all with parser-native locs):
A trailing comment at EOF without a final newline moves onto its own line:
console.log(1);// keep me
(no trailing \n) prints
console.log(1);// keep me
Line-bound directives (eslint-disable-line and friends) stop covering their statement. Root: flush_trailing_comments requires before(comment.loc.end, next) STRICTLY, and at EOF-no-newline the comment ends exactly at Program.loc.end.
prints */\n console.log(1); - note the leading space. The next print of that output drops it, so the first print is not a fixed point.
Comment-only file without a final newline grows a space per print:
// alone
(no trailing \n) prints // alone - the pad space intended for a following statement lands INSIDE the line-comment token, so every reprint grows the comment's text by one space (non-converging).
Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from @typescript-eslint/typescript-estree 8.67 with loc/range enabled, so the repros are independent of our own (oxc-based) pipeline.
Three boundary conditions in the comment flush machinery (all with parser-native locs):
A trailing comment at EOF without a final newline moves onto its own line:
(no trailing
\n) printsLine-bound directives (
eslint-disable-lineand friends) stop covering their statement. Root:flush_trailing_commentsrequiresbefore(comment.loc.end, next)STRICTLY, and at EOF-no-newline the comment ends exactly atProgram.loc.end.Multiline block comment before a statement leaves a stray pad space (the newline after
*/is intentional per multiline block comments should have new line after them #82 - the leftover is the pad):prints
*/\n console.log(1);- note the leading space. The next print of that output drops it, so the first print is not a fixed point.Comment-only file without a final newline grows a space per print:
// alone(no trailing
\n) prints// alone- the pad space intended for a following statement lands INSIDE the line-comment token, so every reprint grows the comment's text by one space (non-converging).Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from
@typescript-eslint/typescript-estree8.67 withloc/rangeenabled, so the repros are independent of our own (oxc-based) pipeline.