diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2024-01-22 17:58:05 -0500 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2024-01-23 11:04:16 -0500 |
commit | 7f51959ff14fbe06bc1afd283d1af17b26161cf4 (patch) | |
tree | 9f9b6e7ba9259640b3f1434847ed88387beab4c2 /bootstraptest | |
parent | b14674b236445fb70f484603e678722760f678f4 (diff) |
YJIT: Move guard up for a case of splat+rest
Previously, YJIT put the guard for having enough items to extract from
splat array at a place where the side exit is invalid, so if the guard
fails, YJIT could raise something other than ArgumentError. Move the
guard up to a place before any stack manipulation.
[Bug #20204]
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 926eaaf8f6..8ae3399dc2 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1,3 +1,38 @@ +# regression test for popping before side exit +assert_equal "ok", %q{ + def foo(a, *) = a + + def call(args, &) + foo(1) # spill at where the block arg will be + foo(*args, &) + end + + call([1, 2]) + + begin + call([]) + rescue ArgumentError + :ok + end +} + +# regression test for send processing before side exit +assert_equal "ok", %q{ + def foo(a, *) = :foo + + def call(args) + send(:foo, *args) + end + + call([1, 2]) + + begin + call([]) + rescue ArgumentError + :ok + end +} + # test discarding extra yield arguments assert_equal "2210150001501015", %q{ def splat_kw(ary) = yield *ary, a: 1 |