summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2025-01-08 08:49:51 -0800
committerGitHub <noreply@github.com>2025-01-08 08:49:51 -0800
commite0d600ec190c64aff76cfcbd6009cffb927da166 (patch)
tree3ef2eba19dc6ab2269b8f0c9f3ccb303f24e2037 /test/ruby
parente728170043ab9afb0f064af2bcfcf6ca06f9573d (diff)
Avoid opt_aset_with optimization inside multiple assignment
Previously, since the opt_aset_with optimization was introduced, use of the opt_aset_with optimization inside multiple assignment would result in a segfault or incorrect instructions. Fixes [Bug #21012] Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12528 Merged-By: jeremyevans <code@jeremyevans.net>
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_assignment.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index 3a8dafb7f0..3d0e773c82 100644
--- a/test/ruby/test_assignment.rb
+++ b/test/ruby/test_assignment.rb
@@ -248,6 +248,16 @@ class TestAssignment < Test::Unit::TestCase
a,b,*c = *[*[1,2]]; assert_equal([1,2,[]], [a,b,c])
end
+ def test_massign_optimized_literal_bug_21012
+ a = []
+ def a.[]=(*args)
+ push args
+ end
+ a["a", "b"], = 1
+ a["a", 10], = 2
+ assert_equal [["a", "b", 1], ["a", 10, 2]], a
+ end
+
def test_assign_rescue
a = raise rescue 2; assert_equal(2, a)
a, b = raise rescue [3,4]; assert_equal([3, 4], [a, b])