Permalink
Browse files

Fixed yielding splatted zarray in c-ng.

  • Loading branch information...
Brian Ford
Brian Ford committed Oct 19, 2009
1 parent f601c72 commit 21361141420fbccf9948a54cfdbdc0e663dfd9a6
Showing with 17 additions and 8 deletions.
  1. +2 −1 lib/compiler-ng/ast/sends.rb
  2. +12 −7 spec/compiler/yield_spec.rb
  3. +3 −0 spec/tags/compiler/yield_tags.txt
@@ -594,7 +594,8 @@ def initialize(line, arguments, unwrap)
@yield_splat = false
if @arguments.splat?
- if @arguments.splat.value.kind_of? ArrayLiteral and not unwrap
+ splat = @arguments.splat.value
+ if (splat.kind_of? ArrayLiteral or splat.kind_of? EmptyArray) and not unwrap
@argument_count += 1
else
@yield_splat = true
@@ -70,14 +70,21 @@
end
end
+ relates "yield([*[]])" do
+ compile do |g|
+ g.make_array 0
+ g.yield_stack 1
+ end
+ end
+
relates "yield([*[1]])" do
parse do
[:yield, [:array, [:splat, [:array, [:lit, 1]]]]]
end
compile do |g|
- g.array_of_splatted_array
-
+ g.push 1
+ g.make_array 1
g.yield_stack 1
end
end
@@ -88,11 +95,9 @@
end
compile do |g|
- g.array_of_splatted_array 2 do
- g.push 1
- g.push 2
- end
-
+ g.push 1
+ g.push 2
+ g.make_array 2
g.yield_stack 1
end
end
@@ -0,0 +1,3 @@
+fails:A Yield node is compiled from 'yield([*[]])'
+fails:A Yield node is compiled from 'yield([*[1]])'
+fails:A Yield node is compiled from 'yield([*[1, 2]])'

0 comments on commit 2136114

Please sign in to comment.