@@ -4162,35 +4162,26 @@ impl<'a> Parser<'a> {
41624162 }
41634163
41644164 /// Look backwards in the token stream and expect that there was only whitespace tokens until the previous newline or beginning of string
4165- pub(crate) fn expect_previously_only_whitespace_until_newline(
4166- &mut self,
4167- ) -> Result<(), ParserError> {
4165+ pub(crate) fn prev_only_whitespace_until_newline(&mut self) -> bool {
41684166 let mut look_back_count = 1;
41694167 loop {
41704168 let prev_token = self.peek_prev_nth_token_no_skip_ref(look_back_count);
41714169 match prev_token.token {
4172- Token::EOF => break,
4170+ Token::EOF => break true ,
41734171 Token::Whitespace(ref w) => match w {
4174- Whitespace::Newline => break,
4172+ Whitespace::Newline => break true ,
41754173 // special consideration required for single line comments since that string includes the newline
41764174 Whitespace::SingleLineComment { comment, prefix: _ } => {
41774175 if comment.ends_with('\n') {
4178- break;
4176+ break true ;
41794177 }
41804178 look_back_count += 1;
41814179 }
41824180 _ => look_back_count += 1,
41834181 },
4184- _ => self.expected(
4185- &format!(
4186- "newline before current token ({})",
4187- self.get_current_token()
4188- ),
4189- prev_token.clone(),
4190- )?,
4182+ _ => break false,
41914183 };
41924184 }
4193- Ok(())
41944185 }
41954186
41964187 /// If the current token is the `expected` keyword, consume it and returns
@@ -16448,7 +16439,12 @@ impl<'a> Parser<'a> {
1644816439 // select 1
1644916440 // go
1645016441 // ```
16451- self.expect_previously_only_whitespace_until_newline()?;
16442+ if !self.prev_only_whitespace_until_newline() {
16443+ parser_err!(
16444+ "GO may only be preceded by whitespace on a line",
16445+ self.peek_token().span.start
16446+ )?;
16447+ }
1645216448
1645316449 let count = loop {
1645416450 // using this peek function because we want to halt this statement parsing upon newline
0 commit comments