1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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))
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yui-knk 2018-06-10 05:02:26 +00:00
parent d89d4e93af
commit aee5c4338b

View file

@ -10263,7 +10263,11 @@ new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_els
{
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);