summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorMax Bernstein <rubybugs@bernsteinbear.com>2026-01-09 14:25:48 -0500
committerGitHub <noreply@github.com>2026-01-09 14:25:48 -0500
commite08f316f28b1ce32b154582ce6ac1d2e1471a5b7 (patch)
tree20f86a9322df6a135138189f4dc33c32b3b498dc /test/ruby
parent51ab7b0405e39d6defe0b236e23f43b42aa6c1da (diff)
YJIT: Add frozen guard for struct aset (#15835)
We used to just skip this check (oops), but we should not allow modifying frozen objects.
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_yjit.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 6488661c2d..53b056d335 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -657,6 +657,26 @@ class TestYJIT < Test::Unit::TestCase
RUBY
end
+ def test_struct_aset_guards_recv_is_not_frozen
+ assert_compiles(<<~RUBY, result: :ok, exits: { opt_send_without_block: 1 })
+ def foo(obj)
+ obj.foo = 123
+ end
+
+ Foo = Struct.new(:foo)
+ obj = Foo.new(123)
+ 100.times do
+ foo(obj)
+ end
+ obj.freeze
+ begin
+ foo(obj)
+ rescue FrozenError
+ :ok
+ end
+ RUBY
+ end
+
def test_getblockparam
assert_compiles(<<~'RUBY', insns: [:getblockparam])
def foo &blk