Commit 803214eb

803214eb41e4Merged

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

Description

codegen: Kernel#itself dispatched on string and symbol receivers

"hello".itself and :foo.itself previously fell through to the unresolved-call path. Add the trivial self-return arm to the string and symbol method dispatch — mirrors the existing arms on int and float receivers.

Fixes #965

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

Details

Commit
803214eb41e4
Parent
7e933baf8dcc

spinel_codegen.rbmodifiedView file

@@ -19686,6 +19686,9 @@
1968619686 # FrozenError below; the mutable_str arm in compile_call_expr
1968719687 # handles the legal case before reaching here. Issues #859,
1968819688 # #886.
19689+ if mname == "itself"
19690+ return rc
19691+ end
1968919692 # Comparable#clamp on string. Issue #899.
1969019693 if mname == "clamp"
1969119694 args_id_clp = @nd_arguments[nid]
@@ -20724,6 +20727,9 @@
2072420727
2072520728 # Symbol methods. rc is a sp_sym expression.
2072620729 def compile_symbol_method_expr(nid, mname, rc)
20730+ if mname == "itself"
20731+ return rc
20732+ end
2072720733 if mname == "is_a?" || mname == "kind_of?"
2072820734 args_id = @nd_arguments[nid]
2072920735 if args_id >= 0