Repository navigation
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
@Alonely0 I checked this against the reworked #209 (d000c63), which now drops the newlines in the parser as you proposed, and all four tests here still fail:
So this PR is still needed for those: |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| .arg("BEGIN { do print \"once\"; while (0) }") | ||
| .succeeds() | ||
| .stdout_only("once\n"); | ||
| } |
There was a problem hiding this comment.
could you please add a test that do i++ while (i < 3) still fails? (gawk rejects it too)
There was a problem hiding this comment.
Added in 5c6db9c: do_while_unterminated_body_fails checks that BEGIN { do i++ while (i < 3); print i } fails with no output. gawk 5.3 gives a syntax error at while for it too. The other do_while tests still pass.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
doonly accepted a braced body that was directly followed bywhile, so two forms that POSIX allows (and gawk and mawk run) were syntax errors:In the POSIX grammar, the body of
dois a statement like any other loop body (Do newline_opt terminated_statement/ a braced action), andnewline_optis allowed beforeWhile.The change, in
parser/src/lib.rs:dobody is parsed withparse_statement_body, aswhileandforalready do, so a single terminated statement (do i++;,do ;,do print "x"on its own line) works.while. The body is always terminated at that point (},;or a newline), so this can't join two statements.do i++ while (...)(no terminator) is still a syntax error, the same as in gawk.I checked 10
doshapes (single statement, braced, newlines around the body, empty body,break/continueinside) against gawk: the output matches for all of them. The 4 new tests intests/by-util/test_awk.rsfail onmainand pass with this change.cargo test --workspacepasses, andcargo fmtandcargo clippy --workspace --all-targets -- -D warningsare clean.I used Claude Code (Opus 5.5) to help investigate and draft this change; I reproduced the bug and checked the fix myself.