@@ -4077,35 +4077,26 @@ impl<'a> Parser<'a> {
40774077 }
40784078
40794079 /// Look backwards in the token stream and expect that there was only whitespace tokens until the previous newline or beginning of string
4080- pub(crate) fn expect_previously_only_whitespace_until_newline(
4081- &mut self,
4082- ) -> Result<(), ParserError> {
4080+ pub(crate) fn prev_only_whitespace_until_newline(&mut self) -> bool {
40834081 let mut look_back_count = 1;
40844082 loop {
40854083 let prev_token = self.peek_prev_nth_token_no_skip_ref(look_back_count);
40864084 match prev_token.token {
4087- Token::EOF => break,
4085+ Token::EOF => break true ,
40884086 Token::Whitespace(ref w) => match w {
4089- Whitespace::Newline => break,
4087+ Whitespace::Newline => break true ,
40904088 // special consideration required for single line comments since that string includes the newline
40914089 Whitespace::SingleLineComment { comment, prefix: _ } => {
40924090 if comment.ends_with('\n') {
4093- break;
4091+ break true ;
40944092 }
40954093 look_back_count += 1;
40964094 }
40974095 _ => look_back_count += 1,
40984096 },
4099- _ => self.expected(
4100- &format!(
4101- "newline before current token ({})",
4102- self.get_current_token()
4103- ),
4104- prev_token.clone(),
4105- )?,
4097+ _ => break false,
41064098 };
41074099 }
4108- Ok(())
41094100 }
41104101
41114102 /// If the current token is the `expected` keyword, consume it and returns
@@ -15295,7 +15286,12 @@ impl<'a> Parser<'a> {
1529515286 // select 1
1529615287 // go
1529715288 // ```
15298- self.expect_previously_only_whitespace_until_newline()?;
15289+ if !self.prev_only_whitespace_until_newline() {
15290+ parser_err!(
15291+ "GO may only be preceded by whitespace on a line",
15292+ self.peek_token().span.start
15293+ )?;
15294+ }
1529915295
1530015296 let count = loop {
1530115297 // using this peek function because we want to halt this statement parsing upon newline
0 commit comments