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

ruby-changes:51415

From: yui-knk <ko1@a...>
Date: Sun, 10 Jun 2018 14:02:31 +0900 (JST)
Subject: [ruby-changes:51415] yui-knk:r63621 (trunk): parse.y: Fix locations of NODE_RESCUE

yui-knk	2018-06-10 14:02:26 +0900 (Sun, 10 Jun 2018)

  New Revision: 63621

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

  Log:
    parse.y: Fix locations of NODE_RESCUE
    
    * parse.y (new_bodystmt): Fix locations of NODE_RESCUE
      to end with nd_else or nd_resq. Before this commit,
      locations of NODE_RESCUE included locations of nd_ensr
      of NODE_ENSURE which is a parent node of NODE_RESCUE.
    
      e.g. The location of the end of NODE_RESCUE is fixed:
    
      ```
      def a
        :b
      rescue
        :c
      ensure
        :d
      end
      ```
    
      * Before
    
      ```
      NODE_RESCUE (line: 2, location: (2,2)-(6,4))
      ```
    
      * After
    
      ```
      NODE_RESCUE (line: 3, location: (2,2)-(5,0))
      ```

  Modified files:
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 63620)
+++ parse.y	(revision 63621)
@@ -10263,7 +10263,11 @@ new_bodystmt(struct parser_params *p, NO https://github.com/ruby/ruby/blob/trunk/parse.y#L10263
 {
     NODE *result = head;
     if (rescue) {
-        result = NEW_RESCUE(head, rescue, rescue_else, loc);
+        NODE *tmp = rescue_else ? rescue_else : rescue;
+        YYLTYPE rescue_loc = code_loc_gen(&head->nd_loc, &tmp->nd_loc);
+
+        result = NEW_RESCUE(head, rescue, rescue_else, &rescue_loc);
+        nd_set_line(result, rescue->nd_loc.beg_pos.lineno);
     }
     else if (rescue_else) {
         result = block_append(p, result, rescue_else);

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

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