From 53b3be5d58a9bf1efce229b3dce723f96e820c79 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 8 Aug 2019 20:02:54 -0700 Subject: Fix parsing of mutiple assignment with rescue modifier Single assignment with rescue modifier applies rescue to the RHS: a = raise rescue 1 # a = (raise rescue 1) Previously, multiple assignment with rescue modifier applied rescue to the entire expression: a, b = raise rescue [1, 2] # (a, b = raise) rescue [1, 2] This makes multiple assignment with rescue modifier consistent with single assignment with rescue modifier, applying rescue to the RHS: a, b = raise rescue [1, 2] # a, b = (raise rescue [1, 2]) Implements [Feature #8239] Fixes [Bug #8279] --- test/ruby/test_assignment.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby/test_assignment.rb') diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb index c1f8c46890..c14568fde3 100644 --- a/test/ruby/test_assignment.rb +++ b/test/ruby/test_assignment.rb @@ -92,6 +92,11 @@ class TestAssignment < Test::Unit::TestCase a,b,*c = *[*[1,2]]; assert_equal([1,2,[]], [a,b,c]) 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]) + end + def test_assign_abbreviated bug2050 = '[ruby-core:25629]' a = Hash.new {[]} -- cgit v1.2.3