will not suggest for postfix operator when can not handle precedences well

This commit is contained in:
yukang 2022-11-26 07:10:04 +08:00
parent dee85a391f
commit ded10a13d2
3 changed files with 43 additions and 11 deletions

View file

@ -1316,7 +1316,11 @@ impl<'a> Parser<'a> {
self.prefix_inc_dec_suggest(base_src, kind, spans).emit(&mut err)
}
UnaryFixity::Post => {
self.postfix_inc_dec_suggest(base_src, kind, spans).emit(&mut err)
// won't suggest since we can not handle the precedences
// for example: `a + b++` has been parsed (a + b)++ and we can not suggest here
if !matches!(base.kind, ExprKind::Binary(_, _, _)) {
self.postfix_inc_dec_suggest(base_src, kind, spans).emit(&mut err)
}
}
}
}