@@ -4250,35 +4250,26 @@ impl<'a> Parser<'a> {
42504250 }
42514251
42524252 /// Look backwards in the token stream and expect that there was only whitespace tokens until the previous newline or beginning of string
4253- pub(crate) fn expect_previously_only_whitespace_until_newline(
4254- &mut self,
4255- ) -> Result<(), ParserError> {
4253+ pub(crate) fn prev_only_whitespace_until_newline(&mut self) -> bool {
42564254 let mut look_back_count = 1;
42574255 loop {
42584256 let prev_token = self.peek_prev_nth_token_no_skip_ref(look_back_count);
42594257 match prev_token.token {
4260- Token::EOF => break,
4258+ Token::EOF => break true ,
42614259 Token::Whitespace(ref w) => match w {
4262- Whitespace::Newline => break,
4260+ Whitespace::Newline => break true ,
42634261 // special consideration required for single line comments since that string includes the newline
42644262 Whitespace::SingleLineComment { comment, prefix: _ } => {
42654263 if comment.ends_with('\n') {
4266- break;
4264+ break true ;
42674265 }
42684266 look_back_count += 1;
42694267 }
42704268 _ => look_back_count += 1,
42714269 },
4272- _ => self.expected(
4273- &format!(
4274- "newline before current token ({})",
4275- self.get_current_token()
4276- ),
4277- prev_token.clone(),
4278- )?,
4270+ _ => break false,
42794271 };
42804272 }
4281- Ok(())
42824273 }
42834274
42844275 /// If the current token is the `expected` keyword, consume it and returns
@@ -17407,7 +17398,12 @@ impl<'a> Parser<'a> {
1740717398 // select 1
1740817399 // go
1740917400 // ```
17410- self.expect_previously_only_whitespace_until_newline()?;
17401+ if !self.prev_only_whitespace_until_newline() {
17402+ parser_err!(
17403+ "GO may only be preceded by whitespace on a line",
17404+ self.peek_token().span.start
17405+ )?;
17406+ }
1741117407
1741217408 let count = loop {
1741317409 // using this peek function because we want to halt this statement parsing upon newline
0 commit comments