summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-07 06:38:49 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-07 06:38:49 +0000
commit15c977803d3e54045ed34d25d56eb11706c0db68 (patch)
treef034f7f2509bcc3d0ddaad494ece18d253498314
parent284e3ae137121c844965db845174350121de5892 (diff)
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
-rw-r--r--parse.y3
1 files changed, 2 insertions, 1 deletions
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)