diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-07 02:36:51 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-07 02:36:51 +0000 |
commit | 2c018e9646436ca1320cce3fc06c1ef8dfcdee5d (patch) | |
tree | 20b132743cf7f87858342a81a60590042de2679c /parse.y | |
parent | d2d4839a390434af70c20f36065b7804597a7337 (diff) |
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))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -9422,15 +9422,16 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLT { 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) { |