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

ruby-changes:48982

From: yui-knk <ko1@a...>
Date: Mon, 11 Dec 2017 08:44:26 +0900 (JST)
Subject: [ruby-changes:48982] yui-knk:r61101 (trunk): parse.y: Fix the last location of NODE_COLON2

yui-knk	2017-12-11 08:44:22 +0900 (Mon, 11 Dec 2017)

  New Revision: 61101

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

  Log:
    parse.y: Fix the last location of NODE_COLON2
    
    * parse.y: Fix to only include a range from primary_value to tCONSTANT.
    
      e.g. The locations of the NODE_COLON2 is fixed:
    
      ```
      A::B ||= 1
      ```
    
      * Before
    
      ```
      NODE_COLON2 (line: 1, code_range: (1,0)-(1,10))
      ```
    
      * After
    
      ```
      NODE_COLON2 (line: 1, code_range: (1,0)-(1,4))
      ```

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 61100)
+++ parse.y	(revision 61101)
@@ -1550,7 +1550,10 @@ command_asgn	: lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1550
 		    }
 		| primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs
 		    {
-			$$ = const_path_field($1, $3, &@$);
+			YYLTYPE location;
+			location.first_loc = @1.first_loc;
+			location.last_loc = @3.last_loc;
+			$$ = const_path_field($1, $3, &location);
 			$$ = new_const_op_assign($$, $4, $5, &@$);
 		    }
 		| primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs
@@ -2214,7 +2217,10 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2217
 		    }
 		| primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs
 		    {
-			$$ = const_path_field($1, $3, &@$);
+			YYLTYPE location;
+			location.first_loc = @1.first_loc;
+			location.last_loc = @3.last_loc;
+			$$ = const_path_field($1, $3, &location);
 			$$ = new_const_op_assign($$, $4, $5, &@$);
 		    }
 		| tCOLON3 tCONSTANT tOP_ASGN arg_rhs

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

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