From 15c977803d3e54045ed34d25d56eb11706c0db68 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Thu, 7 Dec 2017 06:38:49 +0000 Subject: parse.y: Fix locations of array * parse.y (make_array): Set locations of ary to include locations of start token (tLBRACK, tWORDS_BEG, ...) and end token (']', tSTRING_END, ...) of array. e.g. The locations of the NODE_ARRAY is fixed: ``` [1, 2, 3] ``` * Before ``` NODE_ARRAY (line: 1, code_range: (1,1)-(1,8)) ``` * After ``` NODE_ARRAY (line: 1, code_range: (1,0)-(1,9)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parse.y b/parse.y index 4279ea6e3a..12d278a131 100644 --- a/parse.y +++ b/parse.y @@ -551,9 +551,10 @@ static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NO static NODE *new_undef_gen(struct parser_params *parser, NODE *i, const YYLTYPE *location); #define new_undef(i, location) new_undef_gen(parser, i, location) +static NODE *nd_set_loc(NODE *nd, const YYLTYPE *location); static NODE *new_zarray_gen(struct parser_params *parser, const YYLTYPE *location); #define new_zarray(location) new_zarray_gen(parser, location) -#define make_array(ary, location) ((ary) ? (ary) : new_zarray(location)) +#define make_array(ary, location) ((ary) ? (nd_set_loc(ary, location), ary) : new_zarray(location)) static NODE *new_ivar_gen(struct parser_params *parser, ID id, const YYLTYPE *location); #define new_ivar(id, location) new_ivar_gen(parser,id,location) -- cgit v1.2.3