aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-04-24 10:34:02 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commit4d64693c703edbccc5b155072276ce7b8c3becdb (patch)
tree423588954efc5b642fd1748984284df1591ca7d4 /parse.y
parent6a9ce1fea89bc5c6518dd6bb7ff3b824a9321976 (diff)
downloadruby-4d64693c703edbccc5b155072276ce7b8c3becdb.tar.gz
Make ripper support **nil syntax
The on_params hook will use :nil as the keyword rest argument. There is a new on_nokw_param hook as well. This fixes a type issue in the previous code, where an ID was passed where a VALUE was the declared type. The symbol :nil is passed instead of the id.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y12
1 files changed, 9 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index c7c43e3278..c575dfdded 100644
--- a/parse.y
+++ b/parse.y
@@ -1034,6 +1034,7 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
%type <id> p_kwrest
+%type <id> f_no_kwarg
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
/* escaped chars, should be ignored otherwise */
@@ -3247,7 +3248,7 @@ block_args_tail : f_block_kwarg ',' f_kwrest opt_f_block_arg
}
| f_no_kwarg opt_f_block_arg
{
- $$ = new_args_tail(p, Qnone, rb_intern("nil"), $2, &@1);
+ $$ = new_args_tail(p, Qnone, ID2SYM(rb_intern("nil")), $2, &@1);
}
| f_block_arg
{
@@ -4718,7 +4719,7 @@ args_tail : f_kwarg ',' f_kwrest opt_f_block_arg
}
| f_no_kwarg opt_f_block_arg
{
- $$ = new_args_tail(p, Qnone, rb_intern("nil"), $2, &@1);
+ $$ = new_args_tail(p, Qnone, ID2SYM(rb_intern("nil")), $2, &@1);
}
| f_block_arg
{
@@ -4977,6 +4978,11 @@ kwrest_mark : tPOW
;
f_no_kwarg : kwrest_mark keyword_nil
+ {
+ /*%%%*/
+ /*% %*/
+ /*% ripper: nokw_param!(Qnil) %*/
+ }
;
f_kwrest : kwrest_mark tIDENTIFIER
@@ -11136,7 +11142,7 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block,
args->kw_rest_arg = NEW_DVAR(kw_rest_arg, loc);
args->kw_rest_arg->nd_cflag = kw_bits;
}
- else if (kw_rest_arg == rb_intern("nil")) {
+ else if (kw_rest_arg == ID2SYM(rb_intern("nil"))) {
args->no_kwarg = 1;
}
else if (kw_rest_arg) {