Repository navigation
interpreter: match a bare regex against $0 - #139
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
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.
|
GNU awk testsuite comparison: |
|
The three new failures come from the bare regex now being matched against
I can take either of these in a follow-up if you want. |
|
a bunch of jobs are failing |
That would be nice, thanks! Let me take a look at the two PRs tomorrow, I've had a long day. |
Alonely0
left a comment
There was a problem hiding this comment.
Nice! This must have slipped through one of the thousand refactorings of the IR emitter. We could do this a single instruction in the near future, given how common of a pattern this is.
|
Merged, thanks for your contribution! |
A regex on its own, as a pattern or in an expression, never matches. It is lowered as
0 ~ /re/(the number 0) instead of$0 ~ /re/. gawk 5.3.2 vs main:awk '/re/'is the most common awk program, andif (/re/),n += /re/and/a/ || /b/fail the same way.$0 ~ /re/already works.The lowering of
Atom::Regexnow loads field 0 into the register before theMatches, the way$0itself is loaded.New tests
bare_regex_pattern_matches_recordandbare_regex_in_expression_matches_recordfail without the change.cargo test --workspace: 210 passed, clippy and fmt clean. Eleven pattern forms (/x/,!/a/,/a/ || /x/,/^$/,/[[:digit:]]+/,if (/[0-9]/),x = /a/,n += /a/, ...) print the same as gawk.