@@ -4077,35 +4077,26 @@ impl<'a> Parser<'a> {
4077
4077
}
4078
4078
4079
4079
/// 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 {
4083
4081
let mut look_back_count = 1;
4084
4082
loop {
4085
4083
let prev_token = self.peek_prev_nth_token_no_skip_ref(look_back_count);
4086
4084
match prev_token.token {
4087
- Token::EOF => break,
4085
+ Token::EOF => break true ,
4088
4086
Token::Whitespace(ref w) => match w {
4089
- Whitespace::Newline => break,
4087
+ Whitespace::Newline => break true ,
4090
4088
// special consideration required for single line comments since that string includes the newline
4091
4089
Whitespace::SingleLineComment { comment, prefix: _ } => {
4092
4090
if comment.ends_with('\n') {
4093
- break;
4091
+ break true ;
4094
4092
}
4095
4093
look_back_count += 1;
4096
4094
}
4097
4095
_ => look_back_count += 1,
4098
4096
},
4099
- _ => self.expected(
4100
- &format!(
4101
- "newline before current token ({})",
4102
- self.get_current_token()
4103
- ),
4104
- prev_token.clone(),
4105
- )?,
4097
+ _ => break false,
4106
4098
};
4107
4099
}
4108
- Ok(())
4109
4100
}
4110
4101
4111
4102
/// If the current token is the `expected` keyword, consume it and returns
@@ -15295,7 +15286,12 @@ impl<'a> Parser<'a> {
15295
15286
// select 1
15296
15287
// go
15297
15288
// ```
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
+ }
15299
15295
15300
15296
let count = loop {
15301
15297
// using this peek function because we want to halt this statement parsing upon newline
0 commit comments