ruby-changes:48945
From: yui-knk <ko1@a...>
Date: Thu, 7 Dec 2017 11:36:55 +0900 (JST)
Subject: [ruby-changes:48945] yui-knk:r61064 (trunk): parse.y: Fix locations of regexp
yui-knk 2017-12-07 11:36:51 +0900 (Thu, 07 Dec 2017) New Revision: 61064 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61064 Log: parse.y: Fix locations of regexp * parse.y (new_regexp_gen): Always set locations to include locations of tREGEXP_BEG and tREGEXP_END. e.g. The locations of the NODE_LIT is fixed: ``` /a/ ``` * Before ``` NODE_LIT (line: 1, code_range: (1,1)-(1,2)) ``` * After ``` NODE_LIT (line: 1, code_range: (1,0)-(1,3)) ``` Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 61063) +++ parse.y (revision 61064) @@ -9422,15 +9422,16 @@ new_regexp_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9422 { VALUE src = node->nd_lit; nd_set_type(node, NODE_LIT); + nd_set_loc(node, location); add_mark_object(node->nd_lit = reg_compile(src, options)); } break; default: add_mark_object(lit = STR_NEW0()); node = NEW_NODE(NODE_DSTR, lit, 1, new_list(node, location)); - nd_set_loc(node, location); case NODE_DSTR: nd_set_type(node, NODE_DREGX); + nd_set_loc(node, location); node->nd_cflag = options & RE_OPTION_MASK; if (!NIL_P(node->nd_lit)) reg_fragment_check(node->nd_lit, options); for (list = (prev = node)->nd_next; list; list = list->nd_next) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/