Skip to content

Commit 9c52678

Browse files
authored
Merge pull request #12439 from slavapestov/tests-for-greg-fix
Add another test case for <rdar://problem/30651948> / <https://bugs.swift.org/browse/SR-4387>
2 parents 5ff7fa6 + 9a22c3c commit 9c52678

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/NameBinding/name_lookup.swift

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,32 @@ func foo2() {
572572
let x = 5
573573
if x < 0, let x = Optional(1) { } // expected-warning {{immutable value 'x' was never used; consider replacing with '_' or removing it}}
574574
}
575+
576+
struct Person {
577+
let name: String?
578+
}
579+
580+
struct Company { // expected-note 2{{did you mean 'Company'?}}
581+
let owner: Person?
582+
}
583+
584+
func test1() {
585+
let example: Company? = Company(owner: Person(name: "Owner"))
586+
if let person = aCompany.owner, // expected-error {{use of unresolved identifier 'aCompany'}}
587+
let aCompany = example {
588+
_ = person
589+
}
590+
}
591+
592+
func test2() {
593+
let example: Company? = Company(owner: Person(name: "Owner"))
594+
guard let person = aCompany.owner, // expected-error {{use of unresolved identifier 'aCompany'}}
595+
let aCompany = example else { return }
596+
}
597+
598+
func test3() {
599+
var c: String? = "c" // expected-note {{did you mean 'c'?}}
600+
if let a = b = c, let b = c { // expected-error {{use of unresolved identifier 'b'}}
601+
_ = b
602+
}
603+
}

0 commit comments

Comments
 (0)