Skip to content

Commit f950360

Browse files
committed
[TypeChecker] NFC: Add a test-case for rdar://problem/47776586
1 parent 3940ceb commit f950360

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Constraints/optional.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,3 +333,15 @@ func sr_9893_2(cString: UnsafePointer<CChar>) {
333333
}
334334
}
335335
}
336+
337+
// rdar://problem/47776586 - Diagnostic refers to '&' which is not present in the source code
338+
func rdar47776586() {
339+
func foo(_: inout Int) {}
340+
var x: Int? = 0
341+
foo(&x) // expected-error {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
342+
// expected-note@-1 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{7-7=(}} {{9-9=)!}}
343+
344+
var dict = [1: 2]
345+
dict[1] += 1 // expected-error {{value of optional type 'Int?' must be unwrapped to a value of type 'Int'}}
346+
// expected-note@-1 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} {{10-10=!}}
347+
}

0 commit comments

Comments
 (0)