@@ -1617,7 +1617,7 @@ static int looking_at_eol_p(struct parser_params *p);
16171617%type <id> f_kwrest f_label f_arg_asgn call_op call_op2 reswords relop dot_or_colon
16181618%type <id> p_kwrest p_kwnorest p_any_kwrest p_kw_label
16191619%type <id> f_no_kwarg f_any_kwrest args_forward excessed_comma nonlocal_var
1620- %type <ctxt> lex_ctxt k_class k_module /* keep <ctxt> in ripper */
1620+ %type <ctxt> lex_ctxt begin_defined k_class k_module /* keep <ctxt> in ripper */
16211621%token END_OF_INPUT 0 " end-of-input"
16221622%token <id> ' .'
16231623/* escaped chars, should be ignored otherwise */
@@ -2966,9 +2966,9 @@ arg : lhs '=' lex_ctxt arg_rhs
29662966 {
29672967 $$ = logop(p, idOROP, $1 , $3 , &@2 , &@$ );
29682968 }
2969- | keyword_defined opt_nl {p->ctxt.in_defined = 1 ;} arg
2969+ | keyword_defined opt_nl begin_defined arg
29702970 {
2971- p->ctxt.in_defined = 0 ;
2971+ p->ctxt.in_defined = $3 .in_defined ;
29722972 $$ = new_defined(p, $4 , &@$ );
29732973 }
29742974 | arg ' ?' arg opt_nl ' :' arg
@@ -3045,6 +3045,13 @@ lex_ctxt : none
30453045 }
30463046 ;
30473047
3048+ begin_defined : lex_ctxt
3049+ {
3050+ p->ctxt.in_defined = 1 ;
3051+ $$ = $1 ;
3052+ }
3053+ ;
3054+
30483055arg_value : arg
30493056 {
30503057 value_expr ($1 );
@@ -3435,9 +3442,9 @@ primary : literal
34353442 /* % %*/
34363443 /* % ripper: yield0! %*/
34373444 }
3438- | keyword_defined opt_nl ' (' {p->ctxt.in_defined = 1 ;} expr rparen
3445+ | keyword_defined opt_nl ' (' begin_defined expr rparen
34393446 {
3440- p->ctxt.in_defined = 0 ;
3447+ p->ctxt.in_defined = $4 .in_defined ;
34413448 $$ = new_defined(p, $5 , &@$ );
34423449 }
34433450 | keyword_not ' (' expr rparen
0 commit comments