1
Fork 0

Do not ICE when evaluating locals' types of invalid yield

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix #78653.
This commit is contained in:
Esteban Küber 2021-02-17 20:44:00 -08:00
parent 8fe989dd76
commit 3eb454aabe
3 changed files with 30 additions and 0 deletions

View file

@ -2081,6 +2081,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
_ => {
self.tcx.sess.emit_err(YieldExprOutsideOfGenerator { span: expr.span });
// Avoid expressions without types during writeback (#78653).
self.check_expr(value);
self.tcx.mk_unit()
}
}