Skip to content

Commit

Permalink
+ ruby33.y: properly restore in_defined flag, extract begin_defined r…
Browse files Browse the repository at this point in the history
…ule (#973)

This commit tracks upstream commit ruby/ruby@b557855.
  • Loading branch information
iliabylich committed Dec 28, 2023
1 parent 467682c commit f01a39d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/parser/ruby33.y
Original file line number Diff line number Diff line change
Expand Up @@ -911,13 +911,9 @@ rule
{
result = @builder.logical_op(:or, val[0], val[1], val[2])
}
| kDEFINED opt_nl
| kDEFINED opt_nl begin_defined arg
{
@context.in_defined = true
}
arg
{
@context.in_defined = false
@context.in_defined = val[2].in_defined
result = @builder.keyword_cmd(:defined?, val[0], nil, [ val[3] ], nil)
}
| arg tEH arg opt_nl tCOLON arg
Expand Down Expand Up @@ -976,6 +972,11 @@ rule
result = @builder.binary_op(val[0], val[1], val[2])
}

begin_defined: none
{
result = @context.dup
}

arg_value: arg

aref_args: none
Expand Down Expand Up @@ -1251,13 +1252,9 @@ rule
{
result = @builder.keyword_cmd(:yield, val[0])
}
| kDEFINED opt_nl tLPAREN2
{
@context.in_defined = true
}
expr rparen
| kDEFINED opt_nl tLPAREN2 begin_defined expr rparen
{
@context.in_defined = false
@context.in_defined = val[3].in_defined
result = @builder.keyword_cmd(:defined?, val[0],
val[2], [ val[4] ], val[5])
}
Expand Down

0 comments on commit f01a39d

Please sign in to comment.