Commit 74feaff5

74feaff5c3d7Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified

Description

codegen: Regexp#=== dispatched as match?

/foo/ === "foobar" and the case x when /re/ shape previously fell through to the unresolved-call path and raised NoMethodError. CRuby's Regexp#=== is just match? — extend the existing regex-receiver dispatch arm to recognise === and route to sp_re_match_p the same way match? does.

Fixes #975

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
74feaff5c3d7
Parent
f11d33c1d34e

spinel_codegen.rbmodifiedView file

@@ -16257,7 +16257,7 @@
1625716257 # rather than compile_string_method_expr, which wants a string
1625816258 # receiver. Receiver can also be InterpolatedRegularExpressionNode
1625916259 # for `/foo_#{x}/.match?(s)` (rare but valid).
16260- if recv >= 0 && (mname == "match?" || mname == "=~" || mname == "match")
16260+ if recv >= 0 && (mname == "match?" || mname == "=~" || mname == "match" || mname == "===")
1626116261 rpat = regex_pat_c_expr(recv)
1626216262 # regexp-typed receiver (the local stored a real
1626316263 # mrb_regexp_pattern * — typically from an if/else union where
@@ -16272,7 +16272,7 @@
1627216272 arg_ids = get_args(args_id)
1627316273 if arg_ids.length > 0
1627416274 sc = compile_expr(arg_ids[0])
16275- if mname == "match?"
16275+ if mname == "match?" || mname == "==="
1627616276 # Issue #869: 2-arg form starts matching at the given byte
1627716277 # offset (negative counts from the end). Without the _at
1627816278 # helper the position was silently dropped.