Project

General

Profile

Actions

Bug #21776

closed

Binding#local_variable_defined? still supports numbered parameters

Bug #21776: Binding#local_variable_defined? still supports numbered parameters

Added by zverok (Victor Shepelev) 3 days ago. Updated 2 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-12-11T18:57:06Z master d02c971574) +PRISM [x86_64-linux]
[ruby-core:124157]

Description

On the freshest master:

[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:

[1].each { it; p binding.local_variable_defined?(:it) }
#=> false

Updated by mame (Yusuke Endoh) 2 days ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|04494d9e4064a57accc8309da9b35754a3d24973.


Binding#local_variable_defined? must not handle numbered parameters

[Bug #21776]

Updated by mame (Yusuke Endoh) 2 days ago Actions #3 [ruby-core:124167]

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.

Updated by mame (Yusuke Endoh) 2 days ago Actions #4

  • Status changed from Closed to Open

Updated by mame (Yusuke Endoh) 2 days ago Actions #5

  • Status changed from Open to Closed

Applied in changeset git|1794cfe12fe61dedebadead542927f9fef4104eb.


Binding#local_variable_defined? raises a NameError for numbered params.

[Bug #21776]

Actions

Also available in: PDF Atom