[前][次][番号順一覧][スレッド一覧]

ruby-changes:49407

From: nobu <ko1@a...>
Date: Sun, 31 Dec 2017 20:25:45 +0900 (JST)
Subject: [ruby-changes:49407] nobu:r61523 (trunk): parse.y: assignable_error

nobu	2017-12-31 20:25:38 +0900 (Sun, 31 Dec 2017)

  New Revision: 61523

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61523

  Log:
    parse.y: assignable_error
    
    * parse.y (assignable_gen): should return valid NODE always even
      on errors.  [ruby-core:84565] [Bug #14261]

  Modified files:
    trunk/parse.y
    trunk/test/ruby/test_parse.rb
Index: parse.y
===================================================================
--- parse.y	(revision 61522)
+++ parse.y	(revision 61523)
@@ -1984,18 +1984,10 @@ mlhs_node	: user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1984
 lhs		: user_variable
 		    {
 			$$ = assignable(var_field($1), 0, &@$);
-		    /*%%%*/
-			if (!$$) $$ = new_begin(0, &@$);
-		    /*%
-		    %*/
 		    }
 		| keyword_variable
 		    {
 			$$ = assignable(var_field($1), 0, &@$);
-		    /*%%%*/
-			if (!$$) $$ = new_begin(0, &@$);
-		    /*%
-		    %*/
 		    }
 		| primary_value '[' opt_call_args rbracket
 		    {
@@ -9980,11 +9972,13 @@ assignable_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9972
 #ifdef RIPPER
     ID id = get_id(lhs);
 # define assignable_result(x) (lhs)
+# define assignable_error() (lhs)
 # define parser_yyerror(parser, loc, x) (lhs = assign_error_gen(parser, lhs))
 #else
 # define assignable_result(x) assignable_result0(x, location)
+# define assignable_error() new_begin(0, location)
 #endif
-    if (!id) return assignable_result(0);
+    if (!id) return assignable_error();
     switch (id) {
       case keyword_self:
 	yyerror0("Can't change the value of self");
@@ -10047,7 +10041,7 @@ assignable_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L10041
 	compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id));
     }
   error:
-    return assignable_result(0);
+    return assignable_error();
 #undef assignable_result
 #undef parser_yyerror
 }
Index: test/ruby/test_parse.rb
===================================================================
--- test/ruby/test_parse.rb	(revision 61522)
+++ test/ruby/test_parse.rb	(revision 61523)
@@ -746,6 +746,12 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L746
         end
       END
     end
+    assert_raise(SyntaxError) do
+      eval "#{<<~"begin;"}\n#{<<~'end;'}", nil, __FILE__, __LINE__+1
+      begin;
+        x, true
+      end;
+    end
   end
 
   def test_block_dup

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]