Skip to content

Conversation

@trinistr
Copy link
Contributor

@trinistr trinistr commented Nov 6, 2025

While working on #1292, I noticed that spec for #offset is missing a lot of cases that are present in spec for #byteoffset, in particular named captures. So I replaced the spec with that one with appropriate changes, retaining only the special test for Unicode Regexp which apparently doesn't work on Opal.

m = /\A\u3042(.)(.)?(.)\z/.match("\u3042\u3043\u3044")

m.offset(2).should == [nil, nil]
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose all the regexps with Unicode codepoints in it (like /\A\u3042..) have UTF-8 encoding and are not supported by Opal. So it makes sense at least to add a version guard for such cases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the similar test cases for #byteoffset aren't guarded. Nevermind.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, true. Spec for #byteoffset doesn't have any guards however, so I'm not sure what is the point here exactly.

@andrykonchin andrykonchin merged commit 411eb2e into ruby:master Nov 6, 2025
12 checks passed
@andrykonchin
Copy link
Member

Thank you!

@trinistr trinistr deleted the improve-matchdata-offset branch November 7, 2025 14:49
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.

2 participants