When a shareable Proc reads a block parameter (`&b`) of the enclosing method, it gets `nil` if the method did not read `b` before. It does not raise `Ractor::IsolationError` even when the block is not shareable, and it loses the block ev...Eregon (Benoit Daloze)
* [Feature #22523] define_method should make its body shareable when possible, using Ractor.shareable_proc semantics (eregon) * As proposed in #21557, and like #22444 did for `Ractor.new`: `define_method`/`define_singleton_method` make...Eregon (Benoit Daloze)
* [Feature #22520] `{Proc,Method,UnboundMethod}#syntax_tree` should return the block node, not the enclosing call (eregon) * `#syntax_tree` (#21795, experimental, not yet released) returns the call the block is passed to (`CallNode`, ...Eregon (Benoit Daloze)
Calling a shareable Proc which sets `$~` or `$_` directly from the block of `Thread.new` or `Fiber.new` overwrites the `$~` and `$_` of that block: ```ruby set = Ractor.shareable_proc { |s| s =~ /(.)/; $_ = s; nil } p Thread.new {...Eregon (Benoit Daloze)
#22444 made `Ractor.new` use the `Ractor.shareable_proc` semantics from #21557 for its block, and there was some interest in doing the same for `define_method` ([#22444#note-5](https://bugs.ruby-lang.org/issues/22444#note-5)). That was ...Eregon (Benoit Daloze)
`yield` in a block calls the block of the enclosing method. A shareable Proc cannot keep that block: the block (or the Proc it becomes) has its own `self` and environment, which are generally not shareable, and the copied environment of ...Eregon (Benoit Daloze)
`Ractor.shareable_proc` must reject blocks reading an outer variable which may be reassigned, because the shareable Proc copies the variable's value ([Feature #21557]). The "Loop Cases" section of #21557 lists cases which should be `Ract...Eregon (Benoit Daloze)
## Summary Currently, when a `Proc` (or a `Method` defined with `define_method`) comes from a block, `#syntax_tree` returns the call that owns the block (`CallNode`, `SuperNode`, `ForwardingSuperNode`), not the block. I propose return...Eregon (Benoit Daloze)
Nice and agreed, this seems far more convenient and already envisioned in #21557. Maybe we should do the same for `define_method`, but just fallback to current behavior if not possible to make the block shareable (clearly not for this...Eregon (Benoit Daloze)