Skip to content

Commit

Permalink
Restore in_defined flag at nested defined?
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 12, 2023
1 parent fe3eff0 commit b557855
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions parse.y
Expand Up @@ -1617,7 +1617,7 @@ static int looking_at_eol_p(struct parser_params *p);
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var
%type <ctxt> lex_ctxt k_class k_module /* keep <ctxt> in ripper */
%type <ctxt> lex_ctxt begin_defined k_class k_module /* keep <ctxt> in ripper */
%token END_OF_INPUT 0 "end-of-input"
%token <id> '.'
/* escaped chars, should be ignored otherwise */
Expand Down Expand Up @@ -2966,9 +2966,9 @@ arg : lhs '=' lex_ctxt arg_rhs
{
$$ = logop(p, idOROP, $1, $3, &@2, &@$);
}
| keyword_defined opt_nl {p->ctxt.in_defined = 1;} arg
| keyword_defined opt_nl begin_defined arg
{
p->ctxt.in_defined = 0;
p->ctxt.in_defined = $3.in_defined;
$$ = new_defined(p, $4, &@$);
}
| arg '?' arg opt_nl ':' arg
Expand Down Expand Up @@ -3045,6 +3045,13 @@ lex_ctxt : none
}
;

begin_defined : lex_ctxt
{
p->ctxt.in_defined = 1;
$$ = $1;
}
;

arg_value : arg
{
value_expr($1);
Expand Down Expand Up @@ -3435,9 +3442,9 @@ primary : literal
/*% %*/
/*% ripper: yield0! %*/
}
| keyword_defined opt_nl '(' {p->ctxt.in_defined = 1;} expr rparen
| keyword_defined opt_nl '(' begin_defined expr rparen
{
p->ctxt.in_defined = 0;
p->ctxt.in_defined = $4.in_defined;
$$ = new_defined(p, $5, &@$);
}
| keyword_not '(' expr rparen
Expand Down

0 comments on commit b557855

Please sign in to comment.