mruby-regexp: fix wrong comments on the String#split override - #7065
Merged
Conversation
The comment above the `String#split` override says `__split` is aliased in `mrb_mruby_regexp_gem_init` before mrblib loads. Nothing under `mrbgems/mruby-regexp/src/` mentions `__split`, and `mrb_mruby_regexp_gem_init()` defines `Regexp` and `MatchData` and their methods only; it never touches `String`. The alias is made in Ruby, at the top of the class body in the same file. Point the parenthetical at that alias, matching what the three other captured methods in the file already say: `String#[]` reads "aliased as `__aref` above", and `String#[]=` and `String#slice!` say the same for `__aset` and `__slice_bang`. Deleting the clause instead would leave `split` the only one of the four saying nothing about where its fallback comes from. The bintest for the same helper repeats the claim, so correct it there too. Fix the line above the limit conversion as well. It calls the conversion `__to_int` and names `mrb_ensure_integer_type()` behind it. `__to_int` was bound to `mrb_ensure_int_type()`, which differs on a BigInt, and the method is gone: the call is `Integer.__ensure(limit)` now, which the rest of the same comment block already names. Comments only; no behavior change.
|
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 (2)
📝 WalkthroughWalkthroughUpdated comments for ChangesString split documentation
Estimated code review effort: 1 (Trivial) | ~2 minutes Possibly related PRs
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three comments around the
String#splitoverride describe mechanisms that are notthere. Comments only; no behavior change.
__splitis a Ruby alias, not a C onemrbgems/mruby-regexp/mrblib/string_regexp.rbsays:__splitis not installed anywhere in C.mrb_mruby_regexp_gem_init()definesRegexpandMatchDataand their methods only, and never touchesString;nothing under
mrbgems/mruby-regexp/src/mentions__split. The alias is madein Ruby, at the top of the class body in the same file:
The fix points the parenthetical there:
That is the wording the file already uses for its three other captured methods.
String#[]reads "Falls back to the C-defined[](aliased as__arefabove)", and
String#[]=andString#slice!say the same for__asetand__slice_bang. Deleting the clause instead would leavesplitthe only one ofthe four saying nothing about where its fallback comes from.
The bintest repeats it
mrbgems/mruby-bin-mruby/bintest/mruby.rbmakes the same claim about the samehelper, so it is corrected in the same change.
__to_intno longer existsInside the override, the limit conversion is explained as:
# `__to_int` is `mrb_ensure_integer_type()`, which asks the object nothing.Two things are wrong with the one line.
__to_intwas bound tomrb_ensure_int_type(), notmrb_ensure_integer_type(); the two differ on aBigInt, which the first narrows and the second returns unchanged. And
__to_intis gone: it was removed by the change closing #7014, which replaced the call with
Integer.__ensure(limit). The same comment block already names__ensurefivelines on, so the paragraph contradicted itself. It now reads:
# `Integer.__ensure` is `mrb_ensure_int_type()`, which asks the object nothing.Testing
The change touches comments only, so there is nothing to reproduce and no
behavior to compare against CRuby.
ruby -cpasses on both edited files.Summary by CodeRabbit
Documentation
String#splitdelegates to its aliased implementation.String#split.Bug Fixes