Allow trailing commas in MappingPattern

This commit is contained in:
Charlie Marsh 2023-02-22 10:01:30 -05:00
parent 2a8aa6f308
commit b61f4d7b69
4 changed files with 983 additions and 4 deletions

View file

@ -801,7 +801,7 @@ MappingPattern: ast::PatternKind = {
rest: None,
};
},
<location:@L> "{" <e:OneOrMore<MatchMappingEntry>> "}" <end_location:@R> => {
<location:@L> "{" <e:OneOrMore<MatchMappingEntry>> ","? "}" <end_location:@R> => {
let (keys, patterns) = e
.into_iter()
.unzip();
@ -811,14 +811,14 @@ MappingPattern: ast::PatternKind = {
rest: None,
};
},
<location:@L> "{" "**" <rest:Identifier> "}" <end_location:@R> => {
<location:@L> "{" "**" <rest:Identifier> ","? "}" <end_location:@R> => {
return ast::PatternKind::MatchMapping {
keys: vec![],
patterns: vec![],
rest: Some(rest),
};
},
<location:@L> "{" <e:OneOrMore<MatchMappingEntry>> "," "**" <rest:Identifier> "}" <end_location:@R> => {
<location:@L> "{" <e:OneOrMore<MatchMappingEntry>> "," "**" <rest:Identifier> ","? "}" <end_location:@R> => {
let (keys, patterns) = e
.into_iter()
.unzip();