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

ruby-changes:48848

From: yui-knk <ko1@a...>
Date: Fri, 1 Dec 2017 22:40:08 +0900 (JST)
Subject: [ruby-changes:48848] yui-knk:r60965 (trunk): parse.y: Fix locations of NODEs related to for statement

yui-knk	2017-12-01 22:40:03 +0900 (Fri, 01 Dec 2017)

  New Revision: 60965

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

  Log:
    parse.y: Fix locations of NODEs related to for statement
    
    * parse.y: Fix to only include a range of for_var.
    
      e.g. The locations of the NODE_ARGS and NODE_DVAR are fixed:
    
      ```
      for a in m do n end
      ```
    
      * Before
    
      ```
      NODE_ARGS (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 19)
      NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 19)
      ```
    
      * After
    
      ```
      NODE_ARGS (line: 1, first_lineno: 1, first_column: 4, last_lineno: 1, last_column: 5)
      NODE_DVAR (line: 1, first_lineno: 1, first_column: 4, last_lineno: 1, last_column: 5)
      ```

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 60964)
+++ parse.y	(revision 60965)
@@ -2909,22 +2909,22 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2909
 
 			switch (nd_type($2)) {
 			  case NODE_MASGN:
-			    m->nd_next = node_assign($2, new_for(new_dvar(id, &@$), 0, 0, &@$), &@$);
-			    args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@$));
+			    m->nd_next = node_assign($2, new_for(new_dvar(id, &@2), 0, 0, &@2), &@2);
+			    args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@2));
 			    break;
 			  case NODE_LASGN:
 			  case NODE_DASGN:
 			  case NODE_DASGN_CURR:
-			    $2->nd_value = new_dvar(id, &@$);
+			    $2->nd_value = new_dvar(id, &@2);
 			    m->nd_plen = 1;
 			    m->nd_next = $2;
-			    args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, &@$));
+			    args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0, &@2));
 			    break;
 			  default:
 			    {
-				NODE *masgn = new_masgn(new_list($2, &@$), 0, &@$);
-				m->nd_next = node_assign(masgn, new_dvar(id, &@$), &@$);
-				args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@$));
+				NODE *masgn = new_masgn(new_list($2, &@2), 0, &@2);
+				m->nd_next = node_assign(masgn, new_dvar(id, &@2), &@2);
+				args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0, &@2));
 				break;
 			    }
 			}

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

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