fix(parser): fix panic in unexpected token

This commit is contained in:
Boshen 2023-04-10 21:57:31 +08:00
parent aedaa1a110
commit 48736e53af
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1

View file

@ -225,7 +225,9 @@ impl<'a> Parser<'a> {
// The lexer should have reported a more meaningful diagnostic
// when it is a undetermined kind.
if self.cur_kind() == Kind::Undetermined {
return self.lexer.errors.pop().unwrap();
if let Some(error) = self.lexer.errors.pop() {
return error;
}
}
diagnostics::UnexpectedToken(self.cur_token().span()).into()
}