summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2021-12-16 10:19:24 -0800
committerJohn Hawthorn <john@hawthorn.email>2021-12-17 15:26:04 -0800
commit83aa68447c87169b3610b6e04abebdcc592f0c16 (patch)
treefec0232c411aaaebde03b319ec0f6c79b08c23aa /bootstraptest
parent5588aa79d4587956ac1ae1734407f21717ad379a (diff)
YJIT: Allow iseq with both opt and kwargs
Previously we mirrored the fast paths the interpreter had for having only one of kwargs or optional args. This commit aims to combine the cases and reduce complexity. Though this allows calling iseqs which have have both optional and keyword arguments, it requires that all optional arguments are specified when there are keyword arguments, since unspecified optional arguments appear before the kwargs. Support for this can be added a in a future PR.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5285
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 0b2b78ca4a..501f00d5b3 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -2226,6 +2226,14 @@ assert_equal '[1]', %q{
5.times.map { kwargs(value: 1) }.uniq
}
+assert_equal '[:ok]', %q{
+ def kwargs(value:)
+ value
+ end
+
+ 5.times.map { kwargs() rescue :ok }.uniq
+}
+
assert_equal '[[1, 2]]', %q{
def kwargs(left:, right:)
[left, right]
@@ -2247,6 +2255,24 @@ assert_equal '[[1, 2]]', %q{
5.times.map { kwargs(1, kwarg: 2) }.uniq
}
+# optional and keyword args
+assert_equal '[[1, 2, 3]]', %q{
+ def opt_and_kwargs(a, b=2, c: nil)
+ [a,b,c]
+ end
+
+ 5.times.map { opt_and_kwargs(1, c: 3) }.uniq
+}
+
+assert_equal '[[1, 2, 3]]', %q{
+ def opt_and_kwargs(a, b=nil, c: nil)
+ [a,b,c]
+ end
+
+ 5.times.map { opt_and_kwargs(1, 2, c: 3) }.uniq
+}
+
+
# leading and keyword arguments are swapped into the right order
assert_equal '[[1, 2, 3, 4, 5, 6]]', %q{
def kwargs(five, six, a:, b:, c:, d:)