Skip to content

Commit 1267f65

Browse files
committed
Address PR comments on return omission.
1 parent 2493986 commit 1267f65

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5694,9 +5694,7 @@ void Parser::parseAbstractFunctionBody(AbstractFunctionDecl *AFD) {
56945694
if (!Body.hasCodeCompletion() && BS->getNumElements() == 1) {
56955695
auto Element = BS->getElement(0);
56965696
if (auto *stmt = Element.dyn_cast<Stmt *>()) {
5697-
auto kind = AFD->getKind();
5698-
if (kind == DeclKind::Var || kind == DeclKind::Subscript ||
5699-
kind == DeclKind::Func ) {
5697+
if (isa<FuncDecl>(AFD)) {
57005698
if (auto *returnStmt = dyn_cast<ReturnStmt>(stmt)) {
57015699
if (!returnStmt->hasResult()) {
57025700
auto returnExpr = TupleExpr::createEmpty(Context,

lib/SILOptimizer/Mandatory/DataflowDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void diagnoseMissingReturn(const UnreachableInst *UI,
6363
if (numElements > 0) {
6464
auto element = BS->getElement(numElements - 1);
6565
if (auto expr = element.dyn_cast<Expr *>()) {
66-
if (expr->getType()->getCanonicalType() == ResTy->getCanonicalType()) {
66+
if (expr->getType()->isEqual(ResTy)) {
6767
Context.Diags.diagnose(
6868
expr->getStartLoc(),
6969
diag::missing_return_last_expr, ResTy,

0 commit comments

Comments
 (0)