mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
If you want to make the parameter and argument label the same in
places where you don't get the argument label for free (i.e., the
first parameter of a function or a parameter of a subscript),
double-up the identifier:
func translate(dx dx: Int, dy: Int) { }
Make this a warning with Fix-Its to ease migration. Part of
rdar://problem/17218256.
Swift SVN r27715
14 lines
690 B
Swift
14 lines
690 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
func simple_default_args() {
|
|
var f1 : (Int) -> Int = {(x : Int = 1) in x+1} // expected-error{{default argument is only permitted for a non-curried function parameter}}
|
|
var f2 : () -> Int = {(x : Int = 1) in x+1} // expected-error{{could not find an overload for '+' that accepts the supplied arguments}} expected-error{{default argument is only permitted for a non-curried function parameter}}
|
|
}
|
|
|
|
func func_default_args() {
|
|
func has_default_args(x x: Int = 1) -> Int { return x+1 }
|
|
var f1 : (Int) -> Int = has_default_args // okay
|
|
var f2 : () -> Int = has_default_args // expected-error{{(x: Int) -> Int' is not convertible to '() -> Int}}
|
|
}
|
|
|