ruby-changes:44867
From: nobu <ko1@a...>
Date: Wed, 30 Nov 2016 10:40:15 +0900 (JST)
Subject: [ruby-changes:44867] nobu:r56940 (trunk): parse.y: no warning for lambda
nobu 2016-11-30 10:40:11 +0900 (Wed, 30 Nov 2016) New Revision: 56940 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56940 Log: parse.y: no warning for lambda * parse.y (parser_yylex): do not warn parentheses of lambda argument list, because there is no name. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 56939) +++ parse.y (revision 56940) @@ -392,6 +392,8 @@ static int parser_yyerror(struct parser_ https://github.com/ruby/ruby/blob/trunk/parse.y#L392 #define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL) #define NEW_QCALL(q,r,m,a) NEW_NODE(NODE_CALL_Q(q),r,m,a) +#define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest) + static int yylex(YYSTYPE*, struct parser_params*); #ifndef RIPPER @@ -7914,7 +7916,7 @@ parse_ident(struct parser_params *parser https://github.com/ruby/ruby/blob/trunk/parse.y#L7916 command_start = TRUE; } if (kw->id[0] == keyword_do) { - if (lpar_beg && lpar_beg == paren_nest) { + if (lambda_beginning_p()) { lpar_beg = 0; --paren_nest; return keyword_do_LAMBDA; @@ -8520,7 +8522,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8522 else if (IS_SPCARG(-1)) { c = tLPAREN_ARG; } - else if (IS_lex_state(EXPR_ENDFN) && space_seen) { + else if (IS_lex_state(EXPR_ENDFN) && space_seen && !lambda_beginning_p()) { rb_warning0("parentheses after method name is interpreted as"); rb_warning0("an argument list, not a decomposed argument"); } @@ -8558,7 +8560,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8560 case '{': ++brace_nest; - if (lpar_beg && lpar_beg == paren_nest) { + if (lambda_beginning_p()) { SET_LEX_STATE(EXPR_BEG); lpar_beg = 0; --paren_nest; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/