1
Fork 0

fix #104867, Properly handle postfix inc/dec in standalone and subexpr scenarios

This commit is contained in:
yukang 2022-11-25 17:11:47 +08:00
parent 1dda298ad3
commit 7c11a53f9c
7 changed files with 188 additions and 64 deletions

View file

@ -292,7 +292,15 @@ impl<'a> Parser<'a> {
let op_span = self.prev_token.span.to(self.token.span);
// Eat the second `+`
self.bump();
lhs = self.recover_from_postfix_increment(lhs, op_span)?;
let prev_is_semi = {
if let Ok(prev_code) = self.sess.source_map().span_to_prev_source(lhs.span) &&
prev_code.trim_end().ends_with(";") {
true
} else {
false
}
};
lhs = self.recover_from_postfix_increment(lhs, op_span, prev_is_semi)?;
continue;
}