[Typed throws] Record thrown error types and conversions in the AST

For any operation that can throw an error, such as calls, property
accesses, and non-exhaustive do..catch statements, record the thrown
error type along with the conversion from that thrown error to the
error type expected in context, as appropriate. This will prevent
later stages from having to re-compute the conversion sequences.
This commit is contained in:
Doug Gregor
2023-10-24 09:13:33 -07:00
parent 7c6dacb06b
commit 5ad39c84e0
19 changed files with 334 additions and 75 deletions

View File

@@ -253,7 +253,7 @@ private:
auto *POArgList = ArgumentList::forImplicitUnlabeled(Ctx, {DstRef});
auto *POCall = CallExpr::createImplicit(Ctx, PODeclRef, POArgList);
POCall->setThrows(false);
POCall->setThrows(nullptr);
// Create the call to checkExpect.
UnresolvedDeclRefExpr *CheckExpectDRE = new (Ctx)
@@ -263,7 +263,7 @@ private:
ArgumentList::forImplicitUnlabeled(Ctx, {Varname, POCall});
auto *CheckExpectExpr =
CallExpr::createImplicit(Ctx, CheckExpectDRE, CheckArgList);
CheckExpectExpr->setThrows(false);
CheckExpectExpr->setThrows(nullptr);
// Create the closure.
auto *Params = ParameterList::createEmpty(Ctx);
@@ -283,7 +283,7 @@ private:
// Call the closure.
auto *ClosureCall = CallExpr::createImplicitEmpty(Ctx, Closure);
ClosureCall->setThrows(false);
ClosureCall->setThrows(nullptr);
// TODO: typeCheckExpression() seems to assign types to everything here,
// but may not be sufficient in some cases.