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:
Doug Gregor
2015-06-24 16:01:39 +00:00
parent 54979b70a7
commit 149d4bcb95
4 changed files with 18 additions and 1 deletions

View File

@@ -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, "_: ");
}
}
// '...'?