Files
swift-mirror/test/expr/closure/default_args.swift
Doug Gregor b2cc34c241 Remove '#' for making parameter names into argument labels.
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
2015-04-24 23:58:57 +00:00

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}}
}