From 2cbfe3717528d4f7fefd79f098a780e6e16983f4 Mon Sep 17 00:00:00 2001 From: Ilya Bylich Date: Thu, 28 Dec 2023 16:52:59 +0100 Subject: [PATCH] + ruby33.y: properly restore in_defined flag, extract begin_defined rule This commit tracks upstream commit ruby/ruby@b557855. --- lib/parser/ruby33.y | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/parser/ruby33.y b/lib/parser/ruby33.y index 70c48ad75..4f836f7d1 100644 --- a/lib/parser/ruby33.y +++ b/lib/parser/ruby33.y @@ -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 @@ -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 @@ -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]) }