Project

General

Profile

Actions

Bug #21356

open

Error when accessing local variable named "default" with Binding#local_variable_get

Added by richardboehme (Richard Böhme) 1 day ago. Updated 1 day ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-05-21T06:12:18Z master f6cbf499bc) +PRISM [x86_64-linux]
[ruby-core:122215]

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

patch.diff (384 Bytes) patch.diff richardboehme (Richard Böhme), 05/21/2025 08:30 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0