Files
swift-mirror/test/Constraints/closures_swift4.swift
Mark Lacey 9ff4bd51e8 Make closures.swift test compile in both Swift 3 and 4 modes.
Split out the things that are really specific to Swift 3 into a new
closures_swift3.swift.

In the process I found that two things that should compile without error
under -swift-version 4 do not, so those tests are currently in
closures_swift3.swift and I have opened new bugs for the issues:

https://bugs.swift.org/browse/SR-5791
https://bugs.swift.org/browse/SR-5792
2017-08-29 11:42:56 -07:00

21 lines
773 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 4
// <rdar://problem/20371273> Type errors inside anonymous functions don't provide enough information
func f20371273() {
let x: [Int] = [1, 2, 3, 4]
let y: UInt = 4
_ = x.filter { ($0 + y) > 42 } // expected-error {{'+' is unavailable}}
}
// rdar://problem/32432145 - compiler should emit fixit to remove "_ in" in closures if 0 parameters is expected
func r32432145(_ a: () -> ()) {}
r32432145 { _ in let _ = 42 }
// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}}
r32432145 { _ in
// expected-error@-1 {{contextual closure type '() -> ()' expects 0 arguments, but 1 was used in closure body}} {{13-17=}}
print("answer is 42")
}