Commit a3d3929b
a3d3929b5c9aMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 5 files · +2 added · ~3 modified
Description
Resolve implicit-self send(:literal) to a direct call
send(:m, args) / __send__("m", args) / public_send(:m, args) with no
explicit receiver now lowers to a direct implicit-self call to m with the
remaining args, the same static model as the existing textual recv.send(:m)
receiver rewrite. Previously only the explicit-receiver form worked; bare
send(:foo) (at top level or inside a method) failed to resolve.
Done as an AST desugar pass (analyze) rather than a textual rewrite: the bare
send token has no . anchor, so a textual rule would mis-rewrite a send(:
that appears inside a string literal or comment. A non-literal name
(send(meth)) has no static target and is left alone.
Refs #1261.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- a3d3929b5c9a
- Parent
- 0a07a1f61a51
src/analyze.cmodifiedView file
ch |= infer_string_params(c); ch |= infer_default_param_types(c); ch |= desugar_enum_chain_to_a(c); /* each_slice(n).to_a -> .map{|s|s} */ ch |= desugar_implicit_send(c); /* send(:m, a) -> m(a) on self */ ch |= desugar_value_callable_forwards(c); /* &proc -> { |x| proc.call(x) } */ ch |= infer_block_params(c); ch |= infer_for_index(c);src/analyze_internal.hmodifiedView file
Loading diff…
src/analyze_pass.cmodifiedView file
Loading diff…
test/implicit_self_send.rbaddedView file
Loading diff…
test/implicit_self_send.rb.expectedaddedView file
Loading diff…