YJIT: Fix crash when yielding keyword arguments
Previously, the code for dropping surplus arguments when yielding into blocks erroneously attempted to drop keyword arguments when there is in fact no surplus arguments. Fix the condition and test that supplying the exact number of keyword arguments as require compiles without fallback.
This commit is contained in:
parent
37356b713c
commit
c71addc522
Notes:
git
2025-01-04 17:53:38 +00:00
@ -1742,6 +1742,14 @@ class TestYJIT < Test::Unit::TestCase
|
||||
RUBY
|
||||
end
|
||||
|
||||
def test_yield_kwargs
|
||||
assert_compiles(<<~RUBY, result: 3, no_send_fallbacks: true)
|
||||
def req2kws = yield a: 1, b: 2
|
||||
|
||||
req2kws { |a:, b:| a + b }
|
||||
RUBY
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def code_gc_helpers
|
||||
|
@ -8011,14 +8011,14 @@ fn gen_send_iseq(
|
||||
|
||||
// Pop surplus positional arguments when yielding
|
||||
if arg_setup_block {
|
||||
let extras = argc - required_num - opt_num;
|
||||
let extras = argc - required_num - opt_num - kw_arg_num;
|
||||
if extras > 0 {
|
||||
// Checked earlier. If there are keyword args, then
|
||||
// the positional arguments are not at the stack top.
|
||||
assert_eq!(0, kw_arg_num);
|
||||
|
||||
asm.stack_pop(extras as usize);
|
||||
argc = required_num + opt_num;
|
||||
argc = required_num + opt_num + kw_arg_num;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user