This commit is contained in:
nora 2022-06-26 13:06:30 +02:00
parent dc200d2046
commit 37772658bd
6 changed files with 96 additions and 42 deletions

View file

@ -196,13 +196,13 @@ where
first = false;
let (declarator, span) = self.declarator()?;
if let Some((token, span)) = eat!(self, Tok::Punct(Punct::Eq)) {
return Err(ParserError::unsupported(span, &token));
}
let init_decl = InitDecl {
declarator,
init: None,
let init = if eat!(self, Tok::Punct(Punct::Eq)).is_some() {
let expr = self.expr()?;
Some(expr)
} else {
None
};
let init_decl = InitDecl { declarator, init };
init_decls.push((init_decl, span));
}