Skip to content

Commit 4517e76

Browse files
mamerichardboehme
andcommitted
Fix an off-by-one error in the rb_numparam_id_p
[Bug #21356] Co-Authored-By: Richard Böhme <richard.boehme1999@gmail.com>
1 parent 081a44f commit 4517e76

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ bind_local_variables(VALUE bindval)
507507
int
508508
rb_numparam_id_p(ID id)
509509
{
510-
return (tNUMPARAM_1 << ID_SCOPE_SHIFT) <= id && id < ((tNUMPARAM_1 + 10) << ID_SCOPE_SHIFT);
510+
return (tNUMPARAM_1 << ID_SCOPE_SHIFT) <= id && id < ((tNUMPARAM_1 + 9) << ID_SCOPE_SHIFT);
511511
}
512512

513513
/*

test/ruby/test_proc.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,14 +1599,14 @@ def test_overridden_proc
15991599
assert_normal_exit('def proc; end; ->{}.curry', bug8345)
16001600
end
16011601

1602-
def get_binding if: 1, case: 2, when: 3, begin: 4, end: 5
1602+
def get_binding if: 1, case: 2, when: 3, begin: 4, end: 5, default: 6
16031603
a ||= 0
16041604
binding
16051605
end
16061606

16071607
def test_local_variables
16081608
b = get_binding
1609-
assert_equal(%i'if case when begin end a', b.local_variables)
1609+
assert_equal(%i'if case when begin end default a', b.local_variables)
16101610
a = tap {|;x, y| x = y = x; break binding.local_variables}
16111611
assert_equal(%i[a b x y], a.sort)
16121612
end
@@ -1637,6 +1637,7 @@ def test_local_variable_get
16371637
assert_equal(3, b.local_variable_get(:when))
16381638
assert_equal(4, b.local_variable_get(:begin))
16391639
assert_equal(5, b.local_variable_get(:end))
1640+
assert_equal(6, b.local_variable_get(:default)) # [Bug #21356]
16401641
end
16411642

16421643
def test_local_variable_set

0 commit comments

Comments
 (0)