mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fix unexpected "duplicated key name" error in paren-less one line pattern matching
[Bug #18990]
This commit is contained in:
parent
59eadf3d25
commit
db0e0dad11
2 changed files with 24 additions and 4 deletions
16
parse.y
16
parse.y
|
@ -1774,14 +1774,18 @@ expr : command_call
|
||||||
p->ctxt.in_kwarg = 1;
|
p->ctxt.in_kwarg = 1;
|
||||||
$<tbl>$ = push_pvtbl(p);
|
$<tbl>$ = push_pvtbl(p);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
$<tbl>$ = push_pktbl(p);
|
||||||
|
}
|
||||||
p_top_expr_body
|
p_top_expr_body
|
||||||
{
|
{
|
||||||
|
pop_pktbl(p, $<tbl>4);
|
||||||
pop_pvtbl(p, $<tbl>3);
|
pop_pvtbl(p, $<tbl>3);
|
||||||
p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
|
p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
|
||||||
/*%%%*/
|
/*%%%*/
|
||||||
$$ = NEW_CASE3($1, NEW_IN($4, 0, 0, &@4), &@$);
|
$$ = NEW_CASE3($1, NEW_IN($5, 0, 0, &@5), &@$);
|
||||||
/*% %*/
|
/*% %*/
|
||||||
/*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/
|
/*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
|
||||||
}
|
}
|
||||||
| arg keyword_in
|
| arg keyword_in
|
||||||
{
|
{
|
||||||
|
@ -1792,14 +1796,18 @@ expr : command_call
|
||||||
p->ctxt.in_kwarg = 1;
|
p->ctxt.in_kwarg = 1;
|
||||||
$<tbl>$ = push_pvtbl(p);
|
$<tbl>$ = push_pvtbl(p);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
$<tbl>$ = push_pktbl(p);
|
||||||
|
}
|
||||||
p_top_expr_body
|
p_top_expr_body
|
||||||
{
|
{
|
||||||
|
pop_pktbl(p, $<tbl>4);
|
||||||
pop_pvtbl(p, $<tbl>3);
|
pop_pvtbl(p, $<tbl>3);
|
||||||
p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
|
p->ctxt.in_kwarg = $<ctxt>2.in_kwarg;
|
||||||
/*%%%*/
|
/*%%%*/
|
||||||
$$ = NEW_CASE3($1, NEW_IN($4, NEW_TRUE(&@4), NEW_FALSE(&@4), &@4), &@$);
|
$$ = NEW_CASE3($1, NEW_IN($5, NEW_TRUE(&@5), NEW_FALSE(&@5), &@5), &@$);
|
||||||
/*% %*/
|
/*% %*/
|
||||||
/*% ripper: case!($1, in!($4, Qnil, Qnil)) %*/
|
/*% ripper: case!($1, in!($5, Qnil, Qnil)) %*/
|
||||||
}
|
}
|
||||||
| arg %prec tLBRACE_ARG
|
| arg %prec tLBRACE_ARG
|
||||||
;
|
;
|
||||||
|
|
|
@ -1570,6 +1570,18 @@ END
|
||||||
assert_equal false, (1 in 2)
|
assert_equal false, (1 in 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_bug18990
|
||||||
|
{a: 0} => a:
|
||||||
|
assert_equal 0, a
|
||||||
|
{a: 0} => a:
|
||||||
|
assert_equal 0, a
|
||||||
|
|
||||||
|
{a: 0} in a:
|
||||||
|
assert_equal 0, a
|
||||||
|
{a: 0} in a:
|
||||||
|
assert_equal 0, a
|
||||||
|
end
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
def test_single_pattern_error_value_pattern
|
def test_single_pattern_error_value_pattern
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue