diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2023-11-22 09:49:26 -0500 |
---|---|---|
committer | Jemma Issroff <jemmaissroff@gmail.com> | 2023-11-27 12:52:07 -0500 |
commit | 95064bb88db7ff0d71bf9c921b0b87fe1ae712d7 (patch) | |
tree | 786f3b92cb470c8dac2054d79ef6bf83b107354b /test | |
parent | 6d447fa35f877edae96e4a7f98c9f5e70219314b (diff) | |
download | ruby-95064bb88db7ff0d71bf9c921b0b87fe1ae712d7.tar.gz |
[PRISM] Fix compilation for SplatNodes within ArrayNodes
SplatNodes within ArrayNodes (e.g. [*1..2, 3]) need to be special
cased in the compiler because they use a combination of concatarray
and newarray instructions to treat each sequence of splat or non-splat
elements as independent arrays which get concatenated. This commit
implements those cases.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_compile_prism.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index a79db57bb5..a01666ee54 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -488,6 +488,13 @@ module Prism assert_prism_eval("[1, 2, 3]") assert_prism_eval("%i[foo bar baz]") assert_prism_eval("%w[foo bar baz]") + assert_prism_eval("[*1..2]") + assert_prism_eval("[*1..2, 3, 4, *5..6, 7, 8]") + assert_prism_eval("[*1..2, 3, 4, *5..6, 7, 8, *9..11]") + assert_prism_eval("[0, *1..2, 3, 4, *5..6, 7, 8, *9..11]") + assert_prism_eval("[-1, true, 0, *1..2, 3, 4, *5..6, 7, 8, *9..11]") + assert_prism_eval("a = [1,2]; [0, *a, 3, 4, *5..6, 7, 8, *9..11]") + assert_prism_eval("[[*1..2], 3, *4..5]") end def test_AssocNode |