summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-11-24 11:22:54 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2016-11-24 11:22:54 +0900
commit227daa881137d5251e03eea0883b9b574a1f064e (patch)
tree862c40327a26041f4a0535c2abc9085954070308
parent1c9593954bfcdcd1c99732eb572c3995228d8fbb (diff)
downloadmruby-227daa881137d5251e03eea0883b9b574a1f064e.tar.gz
mruby-227daa881137d5251e03eea0883b9b574a1f064e.zip
Relax 'void value expression' check that was too strict
-rw-r--r--mrbgems/mruby-compiler/core/parse.y31
1 files changed, 18 insertions, 13 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y
index ea7f809f3..0ff7d819c 100644
--- a/mrbgems/mruby-compiler/core/parse.y
+++ b/mrbgems/mruby-compiler/core/parse.y
@@ -1098,7 +1098,7 @@ heredoc_end(parser_state *p)
%type <nd> literal numeric cpath symbol
%type <nd> top_compstmt top_stmts top_stmt
%type <nd> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
-%type <nd> expr_value arg0 arg_rhs primary_value
+%type <nd> expr_value arg_rhs primary_value
%type <nd> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
%type <nd> args call_args opt_call_args
%type <nd> paren_args opt_paren_args variable
@@ -1396,7 +1396,7 @@ expr : command_call
{
$$ = call_uni_op(p, cond($2), "!");
}
- | arg0
+ | arg
;
expr_value : expr
@@ -1738,7 +1738,7 @@ reswords : keyword__LINE__ | keyword__FILE__ | keyword__ENCODING__
| keyword_while | keyword_until
;
-arg0 : lhs '=' arg_rhs
+arg : lhs '=' arg_rhs
{
$$ = new_asgn(p, $1, $3);
}
@@ -1911,16 +1911,6 @@ arg0 : lhs '=' arg_rhs
}
;
-arg : arg0
- {
- if (!$1) $$ = new_nil(p);
- else {
- void_expr_error(p, $1);
- $$ = $1;
- }
- }
- ;
-
aref_args : none
| args trailer
{
@@ -1939,8 +1929,14 @@ aref_args : none
;
arg_rhs : arg %prec tOP_ASGN
+ {
+ void_expr_error(p, $1);
+ $$ = $1;
+ }
| arg modifier_rescue arg
{
+ void_expr_error(p, $1);
+ void_expr_error(p, $3);
$$ = new_mod_rescue(p, $1, $3);
}
;
@@ -2030,42 +2026,51 @@ opt_block_arg : ',' block_arg
args : arg
{
+ void_expr_error(p, $1);
$$ = cons($1, 0);
NODE_LINENO($$, $1);
}
| tSTAR arg
{
+ void_expr_error(p, $2);
$$ = cons(new_splat(p, $2), 0);
NODE_LINENO($$, $2);
}
| args ',' arg
{
+ void_expr_error(p, $3);
$$ = push($1, $3);
}
| args ',' tSTAR arg
{
+ void_expr_error(p, $4);
$$ = push($1, new_splat(p, $4));
}
| args ',' heredoc_bodies arg
{
+ void_expr_error(p, $4);
$$ = push($1, $4);
}
| args ',' heredoc_bodies tSTAR arg
{
+ void_expr_error(p, $5);
$$ = push($1, new_splat(p, $5));
}
;
mrhs : args ',' arg
{
+ void_expr_error(p, $3);
$$ = push($1, $3);
}
| args ',' tSTAR arg
{
+ void_expr_error(p, $4);
$$ = push($1, new_splat(p, $4));
}
| tSTAR arg
{
+ void_expr_error(p, $2);
$$ = list1(new_splat(p, $2));
}
;