summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-29 08:58:39 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-10-29 08:58:39 +0900
commitb4229c0a90ef902328e09a92fc5c6e884d01c542 (patch)
treedfab7c68c73dec1efec5fd6284488c38f0451181
parentda3774e5eb6de9dfe5c2ec6f3444c81d22c0e00a (diff)
Restore `in_kwarg` flag properly
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_pattern_matching.rb1
2 files changed, 2 insertions, 1 deletions
diff --git a/parse.y b/parse.y
index e7fcffa2d6..e1fe38e0d7 100644
--- a/parse.y
+++ b/parse.y
@@ -1557,7 +1557,7 @@ expr : command_call
}
p_top_expr_body
{
- p->in_kwarg = !!$<num>2;
+ p->in_kwarg = !!$<num>3;
/*%%%*/
$$ = NEW_CASE3($1, NEW_IN($4, NEW_TRUE(&@4), NEW_FALSE(&@4), &@4), &@$);
rb_warn0L(nd_line($$), "Pattern matching is experimental, and the behavior may change in future versions of Ruby!");
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index cb87529ccf..5283d5ce87 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -1186,6 +1186,7 @@ END
def test_modifier_in
assert_equal true, (1 in a)
assert_equal 1, a
+ assert_valid_syntax "p(({} in a:), a:\n 1)"
end
end
END_of_GUARD