summaryrefslogtreecommitdiffhomepage
path: root/test/t
diff options
context:
space:
mode:
authorcremno <[email protected]>2015-05-31 13:30:49 +0200
committercremno <[email protected]>2015-05-31 13:30:49 +0200
commit5cd877be7f875546dcc03d80aeeddd4bbbcffe3d (patch)
treef35d538f78eefda4ed0b418b56a4be8ed9b2c9db /test/t
parent6a1978c7e1f58d3cda8cca390d65e5f64580b169 (diff)
downloadmruby-5cd877be7f875546dcc03d80aeeddd4bbbcffe3d.tar.gz
mruby-5cd877be7f875546dcc03d80aeeddd4bbbcffe3d.zip
fix masgn nosplat array rhs bug
The rest lhs variable has to be an empty array if rhs is an array with less elements than pre + post lhs variables. The codegen generated OP_ARRAY with an invalid length (such as 127 for *a, b = []) because rn was negative.
Diffstat (limited to 'test/t')
-rw-r--r--test/t/syntax.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/t/syntax.rb b/test/t/syntax.rb
index 070fcbe3b..dc1a4a3b9 100644
--- a/test/t/syntax.rb
+++ b/test/t/syntax.rb
@@ -234,6 +234,20 @@ assert('multiple assignment (rest+post)') do
assert_equal 3, d
end
+assert('multiple assignment (nosplat array rhs)') do
+ a, *b = []
+ *c, d = [0]
+ e, *f, g = [1, 2]
+
+ assert_nil a
+ assert_equal [], b
+ assert_equal [], c
+ assert_equal 0, d
+ assert_equal 1, e
+ assert_equal [], f
+ assert_equal 2, g
+end
+
assert('Return values of case statements') do
a = [] << case 1
when 3 then 2