mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
REVERTME: Temporarily make vars in refutable patterns a warning
Revert "Make function parameters and refutable patterns always
immutable"
This reverts commit 8f2fbdc93a.
Once we have finally merged master into the Swift 2.2 branch to be, we
should revert this commit to turn the errors back on for Swift 3.0.
This commit is contained in:
@@ -179,15 +179,15 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
|
||||
param.LetVarInOutLoc = consumeToken();
|
||||
param.SpecifierKind = ParsedParameter::InOut;
|
||||
} else if (Tok.is(tok::kw_let)) {
|
||||
diagnose(Tok.getLoc(), diag::let_on_param_is_redundant,
|
||||
diagnose(Tok.getLoc(), diag::var_not_allowed_in_pattern,
|
||||
Tok.is(tok::kw_let)).fixItRemove(Tok.getLoc());
|
||||
param.LetVarInOutLoc = consumeToken();
|
||||
param.SpecifierKind = ParsedParameter::Let;
|
||||
} else if (Tok.is(tok::kw_var)) {
|
||||
diagnose(Tok.getLoc(), diag::var_not_allowed_in_pattern)
|
||||
.fixItRemove(Tok.getLoc());
|
||||
diagnose(Tok.getLoc(), diag::var_not_allowed_in_pattern,
|
||||
Tok.is(tok::kw_let)).fixItRemove(Tok.getLoc());
|
||||
param.LetVarInOutLoc = consumeToken();
|
||||
param.SpecifierKind = ParsedParameter::Let;
|
||||
param.SpecifierKind = ParsedParameter::Var;
|
||||
}
|
||||
|
||||
// Redundant specifiers are fairly common, recognize, reject, and recover
|
||||
@@ -855,8 +855,8 @@ ParserResult<Pattern> Parser::parsePattern() {
|
||||
} else {
|
||||
// In an always immutable context, `var` is not allowed.
|
||||
if (alwaysImmutable)
|
||||
diagnose(varLoc, diag::var_not_allowed_in_pattern)
|
||||
.fixItRemove(varLoc);
|
||||
diagnose(varLoc, diag::var_not_allowed_in_pattern, isLetKeyword)
|
||||
.fixItRemove(varLoc);
|
||||
}
|
||||
|
||||
// In our recursive parse, remember that we're in a var/let pattern.
|
||||
@@ -1067,7 +1067,7 @@ ParserResult<Pattern> Parser::parseMatchingPatternAsLetOrVar(bool isLet,
|
||||
diagnose(varLoc, diag::let_pattern_in_immutable_context);
|
||||
|
||||
if (!isLet && InVarOrLetPattern == IVOLP_AlwaysImmutable)
|
||||
diagnose(varLoc, diag::var_not_allowed_in_pattern)
|
||||
diagnose(varLoc, diag::var_not_allowed_in_pattern, isLet)
|
||||
.fixItReplace(varLoc, "let");
|
||||
|
||||
// In our recursive parse, remember that we're in a var/let pattern.
|
||||
|
||||
Reference in New Issue
Block a user