File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -178,6 +178,12 @@ class TypeVariableRefFinder : public ASTWalker {
178178 return Action::Continue (stmt);
179179 }
180180
181+ PreWalkAction walkToDeclPre (Decl *D) override {
182+ // / Decls get type-checked separately, except for PatternBindingDecls,
183+ // / whose initializers we want to walk into.
184+ return Action::VisitChildrenIf (isa<PatternBindingDecl>(D));
185+ }
186+
181187private:
182188 DeclContext *currentClosureDC () const {
183189 return ClosureDCs.empty () ? nullptr : ClosureDCs.back ();
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift
2+
3+ // https://github.com/apple/swift/issues/71273
4+
5+ func bar< R> ( _ fn: ( ) -> R ) { }
6+
7+ // Make sure we don't error here.
8+ func testLocalFn( ) {
9+ bar ( ) {
10+ func foo( ) -> Int { return 0 }
11+ return ( )
12+ }
13+ }
14+
15+ func testLocalBinding( ) {
16+ bar ( ) {
17+ let _ = if . random( ) { return ( ) } else { 0 }
18+ // expected-error@-1 {{cannot 'return' in 'if' when used as expression}}
19+ return ( )
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments