parse.y relies on $$ = $1 before action routines [PATCH]
In perusing parse.y, I came across this pair of action routines:
bv_decls : bvar
$$ = rb_ary_new3(1, $1);
| bv_decls ',' bvar
Here, the call to rb_ary_push($$, $3) is relying on the fact that yacc/bison prefaces each routine's execution with $$=$1. It does so in order to implement the default behavior for rules that have no action routine (the implicit $$ = $1 rule), and while I doubt that will ever change, I don't think it should be relied upon. At the very least, it's a bit confusing at first glance (using $$ before it is set). Notably, other instances of this idiom (undef_list -> fitem | undef_list ',' fitem; f_arg -> f_arg_item | f_arg ',' f_arg_item; f_block_optarg; f_optarg....) use this approach.
It is corrected by simply replacing $$ with $1. A patch is included. No behavior changes, so no test is included.
- parse.y (bv_decls): parse.y relies on $$ = $1 before action routines. a patch from Michael Edgar. [Bug #5303]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
#1 Updated by matz (Yukihiro Matsumoto) over 6 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100