diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2022-01-30 19:01:49 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2022-01-30 19:01:49 +0900 |
commit | 2640161df5cf18d08ec86a0c1b913d4ee99e102a (patch) | |
tree | 391cd9a4c88f530009d87a1c1a7347de3a3f87c5 /bootstraptest | |
parent | 20091ccad34904cb5ded13a8787f6662a8e2df68 (diff) |
merge revision(s) 5414de4b6e4372af832e338f8eb7a9fe8de17c84: [Backport #18453]
YJIT: Fix SP index with optarg and unordered kwarg
Previously when we were calling a method with an optional argument and
multiple keywords arguments which weren't in the order the receiver
expected we would use the wrong SP index to rearrange them.
Fixes Bug #18453
---
bootstraptest/test_yjit.rb | 16 ++++++++++++++++
yjit_codegen.c | 7 +++++--
2 files changed, 21 insertions(+), 2 deletions(-)
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 05947c48ed..30298a820d 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -2280,6 +2280,22 @@ assert_equal '[[1, 2, 3]]', %q{ 5.times.map { opt_and_kwargs(1, 2, c: 3) }.uniq } +# Bug #18453 +assert_equal '[[1, nil, 2]]', %q{ + def opt_and_kwargs(a = {}, b: nil, c: nil) + [a, b, c] + end + + 5.times.map { opt_and_kwargs(1, c: 2) }.uniq +} + +assert_equal '[[{}, nil, 1]]', %q{ + def opt_and_kwargs(a = {}, b: nil, c: nil) + [a, b, c] + end + + 5.times.map { opt_and_kwargs(c: 1) }.uniq +} # leading and keyword arguments are swapped into the right order assert_equal '[[1, 2, 3, 4, 5, 6]]', %q{ |