ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:122215] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get
@ 2025-05-21  8:31 richardboehme via ruby-core
  2025-05-21  9:28 ` [ruby-core:122217] " mame (Yusuke Endoh) via ruby-core
  2025-06-03  6:43 ` [ruby-core:122389] " mame (Yusuke Endoh) via ruby-core
  0 siblings, 2 replies; 3+ messages in thread
From: richardboehme via ruby-core @ 2025-05-21  8:31 UTC (permalink / raw)
  To: ruby-core; +Cc: richardboehme

Issue #21356 has been reported by richardboehme (Richard Böhme).

----------------------------------------
Bug #21356: Error when accessing local variable named "default" with Binding#local_variable_get
https://bugs.ruby-lang.org/issues/21356

* Author: richardboehme (Richard Böhme)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-21T06:12:18Z master f6cbf499bc) +PRISM [x86_64-linux]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:122217] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get
  2025-05-21  8:31 [ruby-core:122215] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get richardboehme via ruby-core
@ 2025-05-21  9:28 ` mame (Yusuke Endoh) via ruby-core
  2025-06-03  6:43 ` [ruby-core:122389] " mame (Yusuke Endoh) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-05-21  9:28 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #21356 has been updated by mame (Yusuke Endoh).


Good catch, you are correct. Thank you! https://github.com/ruby/ruby/pull/13396

----------------------------------------
Bug #21356: Error when accessing local variable named "default" with Binding#local_variable_get
https://bugs.ruby-lang.org/issues/21356#change-113365

* Author: richardboehme (Richard Böhme)
* Status: Open
* ruby -v: ruby 3.5.0dev (2025-05-21T06:12:18Z master f6cbf499bc) +PRISM [x86_64-linux]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:122389] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get
  2025-05-21  8:31 [ruby-core:122215] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get richardboehme via ruby-core
  2025-05-21  9:28 ` [ruby-core:122217] " mame (Yusuke Endoh) via ruby-core
@ 2025-06-03  6:43 ` mame (Yusuke Endoh) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: mame (Yusuke Endoh) via ruby-core @ 2025-06-03  6:43 UTC (permalink / raw)
  To: ruby-core; +Cc: mame (Yusuke Endoh)

Issue #21356 has been updated by mame (Yusuke Endoh).

Status changed from Open to Closed

Fixed by https://github.com/ruby/ruby/pull/13395

----------------------------------------
Bug #21356: Error when accessing local variable named "default" with Binding#local_variable_get
https://bugs.ruby-lang.org/issues/21356#change-113555

* Author: richardboehme (Richard Böhme)
* Status: Closed
* ruby -v: ruby 3.5.0dev (2025-05-21T06:12:18Z master f6cbf499bc) +PRISM [x86_64-linux]
* Backport: 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/
______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-03  6:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-21  8:31 [ruby-core:122215] [Ruby Bug#21356] Error when accessing local variable named "default" with Binding#local_variable_get richardboehme via ruby-core
2025-05-21  9:28 ` [ruby-core:122217] " mame (Yusuke Endoh) via ruby-core
2025-06-03  6:43 ` [ruby-core:122389] " mame (Yusuke Endoh) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).