From 0872ea53303499caf3584e40f2a5438e86eb4fed Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Tue, 4 Jun 2019 23:11:38 +0900 Subject: node.h: Avoid a magic number to represent excessed comma `(ID)1` was assigned to NODE_ARGS#rest_arg for `{|x,| }`. This change removes the magic number by introducing an explicit macro variable for it: NODE_SPECIAL_EXCESSED_COMMA. --- node.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'node.c') diff --git a/node.c b/node.c index 558a4cef47..864e115472 100644 --- a/node.c +++ b/node.c @@ -1010,7 +1010,14 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node) F_INT(nd_ainfo->post_args_num, "count of mandatory post-arguments"); F_NODE(nd_ainfo->post_init, "initialization of post-arguments"); F_ID(nd_ainfo->first_post_arg, "first post argument"); - F_ID(nd_ainfo->rest_arg, "rest argument"); + F_CUSTOM1(nd_ainfo->rest_arg, "rest argument") { + if (node->nd_ainfo->rest_arg == NODE_SPECIAL_EXCESSED_COMMA) { + A("1 (excessed comma)"); + } + else { + A_ID(node->nd_ainfo->rest_arg); + } + } F_ID(nd_ainfo->block_arg, "block argument"); F_NODE(nd_ainfo->opt_args, "optional arguments"); F_NODE(nd_ainfo->kw_args, "keyword arguments"); -- cgit v1.2.1