Actions
Bug #21356
openError when accessing local variable named "default" with Binding#local_variable_get
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-05-21T06:12:18Z master f6cbf499bc) +PRISM [x86_64-linux]
Description
On Ruby master when using Binding#local_variable_get
with the name :default
it raises the following error:
'Binding#local_variable_get': numbered parameter 'default' is not a local variable (NameError)
I saw that this error was introduced in #21049 but it seems like the check for whether the passed variable name is a numbered parameter does not work for the :default
symbol.
I think this might be an off-by-one error in the rb_numparam_id_p
function in proc.c, where instead of adding 9 (the maximum number of numbered parameters) to tNUMPARAM_1 we currently add 10 which then includes the id of default as well? Compiling with this change (see attached diff) fixed the issue but I'm not sure if it might break other things.
Files
Updated by nobu (Nobuyoshi Nakada) about 23 hours ago
- Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
Updated by mame (Yusuke Endoh) about 23 hours ago
Good catch, you are correct. Thank you! https://github.com/ruby/ruby/pull/13396
Actions
Like0
Like0Like0