Commit f78c5792
f78c5792301dMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 4 files · +2 added · ~2 modified
Description
fix(parse,codegen): public_send + send alias for send (#735)
recv.public_send(:foo, args) used to fall through to the
unresolved-call warning. spinel's static dispatch doesn't model
visibility, so public_send is semantically identical to send (and
send). The parser textual-rewrite path already short-circuited
.send(:foo) and .__send__(:foo) to .foo; extend it with two
new entries for .public_send(:foo) and .public_send("foo").
Also widen the codegen-side AST rewrite arm (the path that catches SymbolNode args constructed via reflection) to recognise public_send and send alongside send. Belt-and-suspenders: in practice the parser-side textual rewrite already catches the literal-symbol shape, so the codegen change is a safety net for edge cases the parser path skips.
Test: test/public_send.rb covers public_send with symbol + string args + an int receiver + the unchanged send path.
472 tests pass; optcarrot checksum 59662.
Closes #735
Co-Authored-By: Claude Opus 4.7 [email protected]
Details
- Commit
- f78c5792301d
- Parent
- baa45caa6e94
spinel_codegen.rbmodifiedView file
# outer CallNode's @nd_name and the inner ArgumentsNode's # @nd_args so the dispatch sees the actual method call # signature, then restore. Issue #555 case 12. if mname == "send" && recv >= 0 # `public_send` is identical to `send` for spinel (visibility is # not modeled). Issue #735. if (mname == "send" || mname == "public_send" || mname == "__send__") && recv >= 0 args_id_send = @nd_arguments[nid] if args_id_send >= 0 aa_send = get_args(args_id_send) if aa_send.length >= 1 && @nd_type[aa_send[0]] == "SymbolNode" sym_name_send = @nd_content[aa_send[0]] if sym_name_send != "" && sym_name_send != "send" if sym_name_send != "" && sym_name_send != "send" && sym_name_send != "public_send" && sym_name_send != "__send__" saved_name_send = @nd_name[nid] saved_args_str = @nd_args[args_id_send] new_args_str = ""spinel_parse.cmodifiedView file
Loading diff…
test/public_send.rbaddedView file
Loading diff…
test/public_send.rb.expectedaddedView file
Loading diff…