Bug #21356
closedError when accessing local variable named "default" with Binding#local_variable_get
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) 23 days 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) 23 days ago
Good catch, you are correct. Thank you! https://github.com/ruby/ruby/pull/13396
Updated by mame (Yusuke Endoh) 10 days ago
- Status changed from Open to Closed