[ruby-core:124157] [Ruby Bug#21776] Binding#local_variable_defined? still supports numbered parameters
Issue #21776 has been reported by zverok (Victor Shepelev). ---------------------------------------- Bug #21776: Binding#local_variable_defined? still supports numbered parameters https://bugs.ruby-lang.org/issues/21776 * Author: zverok (Victor Shepelev) * Status: Open * ruby -v: ruby 4.0.0dev (2025-12-11T18:57:06Z master d02c971574) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- On the freshest `master`: ```ruby [1].each {_1; p binding.local_variable_defined?(:_1) } #=> true ``` It is inconsistent with changes in `#local_variables`/`#local_variable_get`/`#local_variable_set`. And inconsistent with handling of `it`: ```ruby [1].each { it; p binding.local_variable_defined?(:it) } #=> false ``` -- https://bugs.ruby-lang.org/
Issue #21776 has been updated by mame (Yusuke Endoh). Thanks! https://github.com/ruby/ruby/pull/15519 will fix the issue. ---------------------------------------- Bug #21776: Binding#local_variable_defined? still supports numbered parameters https://bugs.ruby-lang.org/issues/21776#change-115626 * Author: zverok (Victor Shepelev) * Status: Open * ruby -v: ruby 4.0.0dev (2025-12-11T18:57:06Z master d02c971574) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- On the freshest `master`: ```ruby [1].each {_1; p binding.local_variable_defined?(:_1) } #=> true ``` It is inconsistent with changes in `#local_variables`/`#local_variable_get`/`#local_variable_set`. And inconsistent with handling of `it`: ```ruby [1].each { it; p binding.local_variable_defined?(:it) } #=> false ``` -- https://bugs.ruby-lang.org/
Issue #21776 has been updated by mame (Yusuke Endoh). I noticed that `binding.local_variable_defined?(:@x)` raises `wrong local variable name '@x' for #<Binding:0x00007cd1e95a94d8> (NameError)`. Maybe `binding.local_variable_defined?(:_1)` should raise a similar error because `_1` is not a local variable. I will create a PR. ---------------------------------------- Bug #21776: Binding#local_variable_defined? still supports numbered parameters https://bugs.ruby-lang.org/issues/21776#change-115628 * Author: zverok (Victor Shepelev) * Status: Closed * ruby -v: ruby 4.0.0dev (2025-12-11T18:57:06Z master d02c971574) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- On the freshest `master`: ```ruby [1].each {_1; p binding.local_variable_defined?(:_1) } #=> true ``` It is inconsistent with changes in `#local_variables`/`#local_variable_get`/`#local_variable_set`. And inconsistent with handling of `it`: ```ruby [1].each { it; p binding.local_variable_defined?(:it) } #=> false ``` -- https://bugs.ruby-lang.org/
participants (2)
-
mame (Yusuke Endoh) -
zverok (Victor Shepelev)