summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bootstraptest/test_yjit.rb14
-rw-r--r--yjit/src/codegen.rs2
2 files changed, 15 insertions, 1 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 819d9b9480..69e93cabee 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -3933,3 +3933,17 @@ assert_equal '[true, true, true, true, true]', %q{
end
calling_my_func
}
+
+# Regresssion test: rest and optional and splat
+assert_equal 'true', %q{
+ def my_func(base=nil, *args)
+ [base, args]
+ end
+
+ def calling_my_func
+ array = []
+ my_func(:base, :rest1, *array) == [:base, [:rest1]]
+ end
+
+ calling_my_func
+}
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 7fc110e1dc..3f12d3c273 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -5855,7 +5855,7 @@ fn gen_send_iseq(
// If we have more arguments than required, we need to prepend
// the items from the stack onto the array.
- let diff = (non_rest_arg_count - required_num + opts_filled_with_splat.unwrap_or(0)) as u32;
+ let diff = (non_rest_arg_count - (required_num + opts_filled_with_splat.unwrap_or(0))) as u32;
// diff is >0 so no need to worry about null pointer
asm.comment("load pointer to array elements");