summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2021-07-15 15:35:20 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:37 -0400
commit9a436da064b966c1278ac530c6d6f2d02b0636dc (patch)
tree86ed8ad25318649369c22ca9d1168d25b86bebbe /bootstraptest
parent1943b27fe9f7ad237a1c5119550d2d71958cf4cd (diff)
Ensure we guard the value before we return
Otherwise you can end up not implicitly calling `to_ary`, which if it has side-effects will result in different behavior.
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_yjit.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index 9541be0570..725eca5eb5 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1479,3 +1479,18 @@ assert_equal '2', %q{
expandarray_postarg
expandarray_postarg
}
+
+assert_equal '10', %q{
+ obj = Object.new
+ val = nil
+ obj.define_singleton_method(:to_ary) { val = 10; [] }
+
+ def expandarray_always_call_to_ary(object)
+ * = object
+ end
+
+ expandarray_always_call_to_ary(obj)
+ expandarray_always_call_to_ary(obj)
+
+ val
+}