mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Disallow unnamed function parameters written without the "_:".
Now, instead of writing, e.g.,
func f(Int) { ... }
one must write the more-generally-consistent and explicit
func f(_: Int) { ... }
Fixes rdar://problem/16737312.
Swift SVN r29609
This commit is contained in:
@@ -287,9 +287,16 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SourceLoc typeStartLoc = Tok.getLoc();
|
||||
auto type = parseType(diag::expected_parameter_type);
|
||||
status |= type;
|
||||
param.Type = type.getPtrOrNull();
|
||||
|
||||
// Unnamed parameters must be written as "_: Type".
|
||||
if (param.Type) {
|
||||
diagnose(typeStartLoc, diag::parameter_unnamed)
|
||||
.fixItInsert(typeStartLoc, "_: ");
|
||||
}
|
||||
}
|
||||
|
||||
// '...'?
|
||||
|
||||
Reference in New Issue
Block a user