Reduce double errors for invalid let expressions
Previously some invalid let expressions would result in both a feature error and a parsing error. Avoid this and ensure that we only emit the parsing error when this happens.
This commit is contained in:
parent
2d7a5f528c
commit
b011a0a13b
7 changed files with 1249 additions and 140 deletions
|
@ -2485,9 +2485,6 @@ impl<'a> Parser<'a> {
|
|||
}
|
||||
let expr = self.parse_expr_assoc_with(1 + prec_let_scrutinee_needs_par(), None.into())?;
|
||||
let span = lo.to(expr.span);
|
||||
if is_recovered.is_none() {
|
||||
self.sess.gated_spans.gate(sym::let_chains, span);
|
||||
}
|
||||
Ok(self.mk_expr(span, ExprKind::Let(pat, expr, span, is_recovered)))
|
||||
}
|
||||
|
||||
|
@ -3460,6 +3457,8 @@ impl MutVisitor for CondChecker<'_> {
|
|||
.sess
|
||||
.emit_err(errors::ExpectedExpressionFoundLet { span, reason }),
|
||||
);
|
||||
} else {
|
||||
self.parser.sess.gated_spans.gate(sym::let_chains, span);
|
||||
}
|
||||
}
|
||||
ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, _, _) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue