mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Lock down on the use of default values in patterns and types.
Per previous discussions, we only want to allow default values for uncurried 'func' and 'constructor' parameters, and not for return types or arbitrary tuple types. Introduce this restriction, fixing part of <rdar://problem/13372694>. Swift SVN r6156
This commit is contained in:
@@ -435,38 +435,6 @@ bool Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
|
||||
return Invalid;
|
||||
}
|
||||
|
||||
|
||||
/// value-specifier:
|
||||
/// ':' type-annotation
|
||||
/// ':' type-annotation '=' expr
|
||||
/// '=' expr
|
||||
bool Parser::parseValueSpecifier(TypeLoc &Ty,
|
||||
NullablePtr<Expr> &Init) {
|
||||
// Diagnose when we don't have a type or an expression.
|
||||
if (Tok.isNot(tok::colon) && Tok.isNot(tok::equal)) {
|
||||
diagnose(Tok, diag::expected_type_or_init);
|
||||
// TODO: Recover better by still creating var, but making it have
|
||||
// 'invalid' type so that uses of the identifier are not errors.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse the type if present.
|
||||
if (consumeIf(tok::colon) &&
|
||||
parseTypeAnnotation(Ty, diag::expected_type))
|
||||
return true;
|
||||
|
||||
// Parse the initializer, if present.
|
||||
if (consumeIf(tok::equal)) {
|
||||
NullablePtr<Expr> Tmp = parseExpr(diag::expected_initializer_expr);
|
||||
if (Tmp.isNull())
|
||||
return true;
|
||||
|
||||
Init = Tmp.get();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// diagnoseRedefinition - Diagnose a redefinition error, with a note
|
||||
/// referring back to the original definition.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user