Skip to content

Commit

Permalink
fix splat without assignment; fix mruby#2781
Browse files Browse the repository at this point in the history
The parser generates NODE_NIL for tSTAR without argument in masgns. The
codegen didn't handle that.
  • Loading branch information
cremno committed May 7, 2015
1 parent 2fe556d commit 2aa5939
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/codegen.c
Expand Up @@ -964,6 +964,9 @@ gen_assignment(codegen_scope *s, node *tree, int sp, int val)
genop_peep(s, MKOP_AB(OP_MOVE, cursp(), sp), val);
}
break;
/* splat without assignment */
case NODE_NIL:
break;

default:
#ifdef ENABLE_STDIO
Expand Down
6 changes: 6 additions & 0 deletions test/t/syntax.rb
Expand Up @@ -213,6 +213,12 @@ def b
assert_equal 7, f
end

assert('Splat without assignment') do
* = [0]
a, * = [1, 2]
assert_equal 1, a
end

assert('Return values of case statements') do
a = [] << case 1
when 3 then 2
Expand Down

0 comments on commit 2aa5939

Please sign in to comment.