Skip to content

lexer: a / first on its line opens a regex literal, never a division (#2233) - #2236

Merged
ehartford merged 2 commits into
mainfrom
regex-stmt
Oct 7, 2026
Merged

ehartford merged 2 commits into
mainfrom
regex-stmt

Conversation

@ehartford

@ehartford ehartford commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

The lexer decided regex-vs-division from the previous significant token and skipped NEWLINE, so a statement or tail beginning with a regex literal after a line ending in ) was read as a division with a missing left operand. A newline ends a statement outside every bracket, so a / first on its line at bracket depth 0 starts a regex. Divisions keep every spelling they had; the fixture fails on the previous compiler with "expected expression". The migrate_diff tool drops its workaround.

Fixes #2233. Draft until the stack's battery is green.

Eric Hartford added 2 commits October 6, 2026 19:43
#2233)

The lexer decided regex-vs-division from the previous significant token
and skipped NEWLINE, so a statement or tail beginning with a regex literal
after a line that ended in `)` or an identifier was read as a division
with a missing left operand ("expected expression"). A newline ends a
statement outside every bracket, so a `/` that is the first token on its
line at bracket depth 0 starts a regex; `line_start` and `bracket_depth`
are the two facts the token loop keeps. Divisions keep every spelling
they had. The behavior fixture fails on the previous compiler with
"expected expression".
@ehartford
ehartford added this pull request to stack #2238 October 7, 2026 02:43
@ehartford ehartford changed the title regex stmt lexer: a / first on its line opens a regex literal, never a division (#2233) Oct 7, 2026
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on stack top dd1c22f (seed-driven): gate rc=0 555s, uat rc=0 26s, battery-checks rc=0 823s.

@ehartford
ehartford marked this pull request as ready for review October 7, 2026 03:12
@ehartford
ehartford merged commit e58747d into main Oct 7, 2026
@ehartford
ehartford deleted the regex-stmt branch October 7, 2026 03:12
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.

parser: a regex literal cannot open a statement or tail expression ('expected expression')

1 participant