From: "mame (Yusuke Endoh)" Date: 2022-07-20T01:58:30+00:00 Subject: [ruby-core:109253] [Ruby master Bug#18837] Not possible to evaluate expression with numbered parameters in it Issue #18837 has been updated by mame (Yusuke Endoh). I talked a bit with some of the committers. @ko1 said that it is difficult to retrieve `_1` afterwards due to the current implementation limitation, since the actual arguments may be dropped by optimization when a block that does not accept formal arguments is called. Also, @znz pointed out that the meta-programming API to read out only `_1` is somewhat unreasonable, since the meaning of `_1` depends on the presence of _2. ``` { 1 => "A" }.each do p _1 #=> [1, "A"] end { 1 => "A" }.each do p _1 #=> 1 _2 end ``` ---------------------------------------- Bug #18837: Not possible to evaluate expression with numbered parameters in it https://bugs.ruby-lang.org/issues/18837#change-98385 * Author: hurricup (Alexandr Evstigneev) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- I presume it's not really a bug, but design flaw, but this is really frustrating. Use case is - debugger. Here is script with expected behavior: ``` def dumper(bnd) puts bnd.local_variable_get 'i' puts bnd.eval 'i * 10' end [1,2].each { |i| dumper(binding) } ``` And this one attempts to do the same with numbered params: ``` def dumper(bnd) puts bnd.local_variable_get('_1') puts bnd.eval '_1 * 10' end [1,2].each do some = _1 # without this line even local_variable_get won't work, still it may be in any place of block dumper(binding) end ``` But `eval` wont ever work and this necessity for using `_1` so binding could see it may be confusing as well. -- https://bugs.ruby-lang.org/ Unsubscribe: