@@ -5522,19 +5522,32 @@ impl<'a> Parser<'a> {
55225522 // peek the next token, which if it is another type keyword, then the
55235523 // first token is a name and not a type in itself.
55245524 let data_type_idx = self.get_current_index();
5525- // DEFAULT will be parsed as `DataType::Custom`, which is undesirable in this context
5526- if !self.peek_keyword(Keyword::DEFAULT) {
5527- if let Some(next_data_type) = self.maybe_parse(|parser| parser.parse_data_type())? {
5528- let token = self.token_at(data_type_idx);
55295525
5530- // We ensure that the token is a `Word` token, and not other special tokens.
5531- if !matches!(token.token, Token::Word(_)) {
5532- return self.expected("a name or type", token.clone());
5533- }
5526+ // FIXME: DEFAULT will be parsed as `DataType::Custom`, which is undesirable in this context
5527+ fn parse_data_type_no_default(
5528+ parser: &mut Parser,
5529+ ) -> Result<DataType, ParserError> {
5530+ if parser.peek_keyword(Keyword::DEFAULT) {
5531+ // This dummy error is ignored in `maybe_parse`
5532+ parser_err!(
5533+ "The DEFAULT keyword is not a type",
5534+ parser.peek_token().span.start
5535+ )
5536+ } else {
5537+ parser.parse_data_type()
5538+ }
5539+ }
55345540
5535- name = Some(Ident::new(token.to_string()));
5536- data_type = next_data_type;
5541+ if let Some(next_data_type) = self.maybe_parse(parse_data_type_no_default)? {
5542+ let token = self.token_at(data_type_idx);
5543+
5544+ // We ensure that the token is a `Word` token, and not other special tokens.
5545+ if !matches!(token.token, Token::Word(_)) {
5546+ return self.expected("a name or type", token.clone());
55375547 }
5548+
5549+ name = Some(Ident::new(token.to_string()));
5550+ data_type = next_data_type;
55385551 }
55395552
55405553 let default_expr = if self.parse_keyword(Keyword::DEFAULT) || self.consume_token(&Token::Eq)
0 commit comments