@@ -4187,35 +4187,26 @@ impl<'a> Parser<'a> {
41874187 }
41884188
41894189 /// Look backwards in the token stream and expect that there was only whitespace tokens until the previous newline or beginning of string
4190- pub(crate) fn expect_previously_only_whitespace_until_newline(
4191- &mut self,
4192- ) -> Result<(), ParserError> {
4190+ pub(crate) fn prev_only_whitespace_until_newline(&mut self) -> bool {
41934191 let mut look_back_count = 1;
41944192 loop {
41954193 let prev_token = self.peek_prev_nth_token_no_skip_ref(look_back_count);
41964194 match prev_token.token {
4197- Token::EOF => break,
4195+ Token::EOF => break true ,
41984196 Token::Whitespace(ref w) => match w {
4199- Whitespace::Newline => break,
4197+ Whitespace::Newline => break true ,
42004198 // special consideration required for single line comments since that string includes the newline
42014199 Whitespace::SingleLineComment { comment, prefix: _ } => {
42024200 if comment.ends_with('\n') {
4203- break;
4201+ break true ;
42044202 }
42054203 look_back_count += 1;
42064204 }
42074205 _ => look_back_count += 1,
42084206 },
4209- _ => self.expected(
4210- &format!(
4211- "newline before current token ({})",
4212- self.get_current_token()
4213- ),
4214- prev_token.clone(),
4215- )?,
4207+ _ => break false,
42164208 };
42174209 }
4218- Ok(())
42194210 }
42204211
42214212 /// If the current token is the `expected` keyword, consume it and returns
@@ -16542,7 +16533,12 @@ impl<'a> Parser<'a> {
1654216533 // select 1
1654316534 // go
1654416535 // ```
16545- self.expect_previously_only_whitespace_until_newline()?;
16536+ if !self.prev_only_whitespace_until_newline() {
16537+ parser_err!(
16538+ "GO may only be preceded by whitespace on a line",
16539+ self.peek_token().span.start
16540+ )?;
16541+ }
1654616542
1654716543 let count = loop {
1654816544 // using this peek function because we want to halt this statement parsing upon newline
0 commit comments