1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Allow newlines inside braced pattern

This commit is contained in:
Nobuyoshi Nakada 2020-03-02 15:49:03 +09:00
parent 0711ceeb37
commit f5c904c2a9
No known key found for this signature in database
GPG key ID: 4BC7D6DF58D8DF60
2 changed files with 24 additions and 2 deletions

12
parse.y
View file

@ -3955,12 +3955,17 @@ p_expr_basic : p_value
$$ = new_array_pattern_tail(p, Qnone, 0, 0, Qnone, &@$);
$$ = new_array_pattern(p, Qnone, Qnone, $$, &@$);
}
| tLBRACE {$<tbl>$ = push_pktbl(p);} p_kwargs '}'
| tLBRACE
{
$<tbl>$ = push_pktbl(p);
p->in_kwarg = 0;
}
p_kwargs rbrace
{
pop_pktbl(p, $<tbl>2);
$$ = new_hash_pattern(p, Qnone, $3, &@$);
}
| tLBRACE '}'
| tLBRACE rbrace
{
$$ = new_hash_pattern_tail(p, Qnone, 0, &@$);
$$ = new_hash_pattern(p, Qnone, $$, &@$);
@ -5420,6 +5425,9 @@ rparen : opt_nl ')'
rbracket : opt_nl ']'
;
rbrace : opt_nl '}'
;
trailer : /* none */
| '\n'
| ','

View file

@ -1051,6 +1051,20 @@ END
end
end
assert_block do
case {a: 0}
in {a: 1
}
false
in {a:
2}
false
in {a:
}
true
end
end
assert_syntax_error(%q{
case _
in "a-b":