Files
swift-mirror/test/decl/func/arg_rename.swift
Chris Lattner 5ce3de8dd6 remove & dial back three old bits of syntax auto-upgrading support:
1. Array type parsing for postfix array types Int[].  We now handle this
   in the parser, but remove the AST representation of this old form.  We
   also stop making vague promises about the future by saying that "fixed
   size arrays aren't supported... yet".  Removal of this fixes a compiler
   crasher too.

2. Remove the special case support for migrating @autoclosure from types
   to parameters, which was Swift 1.0/1.1 syntax.  The world has moved or
   we don't care anymore.

3. Remove upgrade support for # arguments (nee "backtick" arguments), which
   was a Swift 1.x'ism abolished in an effort to simplify method naming
   rules.

NFC on valid code.
2015-12-31 22:29:39 -08:00

53 lines
1.3 KiB
Swift

// RUN: %target-parse-verify-swift
// Renaming of arguments.
func foo(a x: Int, b y: Int) { }
foo(a: 5, b: 7)
func bar<T>(a x: T, b y: T) { }
bar(a: 5, b: 7)
// Renaming of arguments in initializers.
struct S {
init(a x: Int, b y: Int) { }
}
S(a: 5, b: 7) // expected-warning{{unused}}
struct GS {
init<T>(a x: T, b y: T) { }
}
GS(a: 5, b: 7) // expected-warning{{unused}}
// Using the hash to make a name API.
func f1(a a: Int, b: Int) { }
f1(a: 1, b: 2)
func f2(class cls: Int) { }
f2(class: 5)
func g2(a a: Int) { }
func g5(_ a: Int) { }
// expected-warning@-1{{extraneous '_' in parameter: 'a' has no keyword argument name}}{{9-11=}}
class X {
init(a a: Int) { } // expected-warning{{extraneous duplicate parameter name; 'a' already has an argument label}}{{8-10=}}
func f1(a a: Int, b: Int) { }
func f2(a: Int, b b: Int) { } // expected-warning{{extraneous duplicate parameter name; 'b' already has an argument label}}{{19-21=}}
func f3(_ a: Int, b: Int) { }
// expected-warning@-1{{extraneous '_' in parameter: 'a' has no keyword argument name}}{{11-13=}}
}
// Operators never have keyword arguments.
infix operator +++ { }
func +++(lhs lhs: Int, // expected-error{{operator cannot have keyword arguments}}{{10-14=}}
rhs x: Int) -> Int { // expected-error{{operator cannot have keyword arguments}}{{10-14=}}
return lhs + x
}