mruby-regexp: say at each block why only a byte-indexed subject can answer - #7121
Conversation
|
Sorry for the timing on this one: I merged #7120 shortly before this arrived, so master already carries the deletions. That was my doing rather than anything wrong with how you split it. I compared the two before deciding what to ask for. Sorting the What is not in is the part I would still like, which is the writing. Your comments here say, at the point each block asks, why a subject read as UTF-8 has no answer to give; #7120 left that reasoning spread across the blocks in a way that reads less clearly. The ordering differs too, keeping the byte-indexed assertions together rather than interleaved with the ones a whole character answers. It does not apply as it stands, since the two reworked the same lines. Could you rebase it onto master? Whatever survives as a real diff after that is what I want. If that turns out to be only comments and ordering, that is fine and worth a commit of its own. One thing worth saying about the series rather than this piece. Landing #7115 and #7116 first is what made these deletions easy to accept: every assertion dropped here already had a counterpart putting the same question to the engine through a subject that can answer it, so I could check that the byte-indexed count came out unchanged rather than read 41 deletions one at a time. Deleting tests is the part of a change that is hardest to review on trust, and building the replacement first is what turned it into a count I could verify. |
…nswer Nine blocks ask what the engine does with a byte that stands for no character, and each of them asks a byte-indexed subject alone. Why that is the only subject with an answer to give is not stated anywhere, and what stands in its place is spread over the blocks and does not hold together. Two of them say the whole-character subject "goes through as it always did" and "reaches the engine as it always did", which describes a refusal this tree does not have; a third says a subject read as UTF-8 "no longer reaches the engine at all", which is not true here either. Say it once, where the first of these blocks asks: a subject read as UTF-8 spells no character where such a byte is, so what a quantifier binds to there, whether a class holds the byte, where a match may start and how far a walk reads are whatever a decoder happens to do with input no rule covers, and an assertion on one pins that accident rather than the pattern. Each block below then says in a line which of its subjects carries the byte and why that one is byte-indexed. Three blocks left a whole-character assertion among the byte-indexed ones. Move each to the front of its block, where what a UTF-8 subject is left to answer reads on its own: `.` takes one atom, no match position opens inside a character, and the shortest spelling on each side of the RFC 3629 bounds is one character. That last group used to be introduced as "those bounds", which named the surrogate cases sitting above it, so it names the bounds itself now. No assertion is added, removed or changed.
8b9efe2 to
7fec25d
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe UTF-8 regexp tests now use clearer comments, improved assertion placement, and reordered malformed and valid UTF-8 cases. Production APIs and test behavior remain unchanged. ChangesUTF-8 regexp test coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Rebased. What survived is the writing and the ordering, and I checked it the Two things I did not carry over from the version you read. The first is that it deleted line comments describing assertions that stay. The second is One thing the rebase turned up. Three comments describe a refusal this tree does And thank you for saying what made the deletions reviewable. I had thought of |
Rebased onto master, which carries #7120. The deletions this pull request also
made are already in, so what is left is the writing and the ordering, which is
what the review comment on this pull request asked for.
Test only, and no assertion is added, removed or changed: sorting the
assertlines of the file before and after and diffing them turns up nothing.
What the comments say now
Nine blocks ask what the engine does with a byte that stands for no character,
and since #7115 and #7116 each asks a byte-indexed subject alone. Why that is
the only subject with an answer to give was not stated anywhere. The first of
these blocks now says it once:
Each block below then says in a line which of its subjects carries the byte and
why that one is byte-indexed, at the point it asks.
Three comments described a refusal this tree does not have yet: two say the
whole-character subject "goes through as it always did" and "reaches the engine
as it always did", and one says a subject read as UTF-8 "no longer reaches the
engine at all". Each is now written for what the engine does today.
Ordering
Three blocks left a whole-character assertion among the byte-indexed ones.
quantifier on an invalid multibyte literal"Ā".match(/./)a byte that belongs to no character is a match positionassert_nilon a whole characteroverlong UTF-8 is not the character it spellsThe comment introducing the surrogate cases said "those bounds", which named
the group that used to sit above it, so it names the bounds itself now.
a pattern byte that starts no character is a byte in a classkeeps itsordering. Every byte-indexed assertion there is written next to the whole
character carrying the same byte, and the pair is what the block is about: the
byte answers for itself, the character for the character. Grouping them apart
would separate each line comment from the assertion it describes.
Verified
rake teston a full-core build (MRB_UTF8_STRINGthrough mruby-encoding):2254 tests, all green
rake teston the default gembox (noMRB_UTF8_STRING): 2061 tests, allgreen
prek runon the file passesSummary by CodeRabbit