ruby-changes:48951
From: yui-knk <ko1@a...>
Date: Thu, 7 Dec 2017 15:38:54 +0900 (JST)
Subject: [ruby-changes:48951] yui-knk:r61070 (trunk): parse.y: Fix locations of array
yui-knk 2017-12-07 15:38:49 +0900 (Thu, 07 Dec 2017) New Revision: 61070 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61070 Log: 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)) ``` Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 61069) +++ parse.y (revision 61070) @@ -551,9 +551,10 @@ static NODE *new_rescue_gen(struct parse https://github.com/ruby/ruby/blob/trunk/parse.y#L551 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/