Skip to content

Commit 213ad8a

Browse files
authored
Merge pull request #83096 from hamishknight/ret
[Sema] Set ReturnStmt result even if type-checking fails
2 parents d7ec3a3 + 72db180 commit 213ad8a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,9 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
10911091
if (resultTarget) {
10921092
RS->setResult(resultTarget->getAsExpr());
10931093
} else {
1094+
// Update the expression even if type-checking failed as e.g pre-checking
1095+
// may have folded a sequence expr.
1096+
RS->setResult(target.getAsExpr());
10941097
tryDiagnoseUnnecessaryCastOverOptionSet(getASTContext(), RS->getResult(),
10951098
ResultTy);
10961099
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// {"kind":"complete","original":"089853e1","signature":"swift::TypeChecker::typeCheckForCodeCompletion(swift::constraints::SyntacticElementTarget&, bool, llvm::function_ref<void (swift::constraints::Solution const&)>)"}
2+
// RUN: %target-swift-ide-test -code-completion -batch-code-completion -skip-filecheck -code-completion-diagnostics -source-filename %s
3+
struct a {
4+
b:
5+
func c -> UInt32 {
6+
0 ^ b#^^#

0 commit comments

Comments
 (0)