aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-03-03 15:48:53 +0900
committerNARUSE, Yui <naruse@airemix.jp>2020-03-28 04:01:15 +0900
commit44f7e3883e49d287a96f7ef36b5c935d833300e5 (patch)
tree7b83ae5e36ea708fe3876af6785e57e5717f5f4e
parentaeda3a7f036aa7c768abffd1965972c658f49c22 (diff)
downloadruby-44f7e3883e49d287a96f7ef36b5c935d833300e5.tar.gz
Preserve `kwarg` flag and fix up f5c904c2a9
(cherry picked from commit c8d0bf0156878df03a71fffc97c44abf7333d5d7)
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_pattern_matching.rb2
2 files changed, 4 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index d249039024..d34d3f9adb 100644
--- a/parse.y
+++ b/parse.y
@@ -3940,11 +3940,13 @@ p_expr_basic : p_value
| tLBRACE
{
$<tbl>$ = push_pktbl(p);
+ $<num>1 = p->in_kwarg;
p->in_kwarg = 0;
}
p_kwargs rbrace
{
pop_pktbl(p, $<tbl>2);
+ p->in_kwarg = $<num>1;
$$ = new_hash_pattern(p, Qnone, $3, &@$);
}
| tLBRACE rbrace
diff --git a/test/ruby/test_pattern_matching.rb b/test/ruby/test_pattern_matching.rb
index 3eea523416..3c4314bbe4 100644
--- a/test/ruby/test_pattern_matching.rb
+++ b/test/ruby/test_pattern_matching.rb
@@ -1060,6 +1060,8 @@ END
in {a:
2}
false
+ in a: {b:}, c:
+ p c
in {a:
}
_a = a