From 547dec58cec2adbc4e6159281aeacd6902fa46d4 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 21:54:38 +0900 Subject: [PATCH 01/10] [ConstraintSystem] add new locator path element `ArgumentLabel` --- lib/Sema/ConstraintLocator.cpp | 9 +++++++++ lib/Sema/ConstraintLocator.h | 13 +++++++++++++ lib/Sema/ConstraintLocatorPathElts.def | 3 +++ 3 files changed, 25 insertions(+) diff --git a/lib/Sema/ConstraintLocator.cpp b/lib/Sema/ConstraintLocator.cpp index 10a76299ef8f9..abd5d7228b525 100644 --- a/lib/Sema/ConstraintLocator.cpp +++ b/lib/Sema/ConstraintLocator.cpp @@ -62,6 +62,7 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, ASTNode anchor, case NamedTupleElement: case TupleElement: case ApplyArgToParam: + case ArgumentLabel: case OpenedGeneric: case KeyPathComponent: case ConditionalRequirement: @@ -85,6 +86,7 @@ void ConstraintLocator::Profile(llvm::FoldingSetNodeID &id, ASTNode anchor, unsigned LocatorPathElt::getNewSummaryFlags() const { switch (getKind()) { + case ConstraintLocator::ArgumentLabel: case ConstraintLocator::ApplyArgument: case ConstraintLocator::ApplyFunction: case ConstraintLocator::SequenceElementType: @@ -327,6 +329,13 @@ void ConstraintLocator::dump(SourceManager *sm, raw_ostream &out) const { out << " (non-ephemeral)"; break; } + + case ArgumentLabel: { + auto argElt = elt.castTo(); + out << "argument label #" << llvm::utostr(argElt.getArgIdx()); + break; + } + case ClosureResult: out << "closure result"; break; diff --git a/lib/Sema/ConstraintLocator.h b/lib/Sema/ConstraintLocator.h index 211fe8e06ae54..1c32e08867e87 100644 --- a/lib/Sema/ConstraintLocator.h +++ b/lib/Sema/ConstraintLocator.h @@ -77,6 +77,7 @@ class ConstraintLocator : public llvm::FoldingSetNode { return 0; case ClosureBody: + case ArgumentLabel: case ContextualType: case OpenedGeneric: case GenericArgument: @@ -602,6 +603,18 @@ class LocatorPathElt::ApplyArgToParam final : public LocatorPathElt { } }; +class LocatorPathElt::ArgumentLabel final : public LocatorPathElt { +public: + ArgumentLabel(unsigned argIdx) + : LocatorPathElt(ConstraintLocator::ArgumentLabel, argIdx) {} + + unsigned getArgIdx() const { return getValue(0); } + + static bool classof(const LocatorPathElt *elt) { + return elt->getKind() == ConstraintLocator::ArgumentLabel; + } +}; + class LocatorPathElt::SynthesizedArgument final : public LocatorPathElt { public: SynthesizedArgument(unsigned index) diff --git a/lib/Sema/ConstraintLocatorPathElts.def b/lib/Sema/ConstraintLocatorPathElts.def index 856b13bac83e5..d6add7a4a04c4 100644 --- a/lib/Sema/ConstraintLocatorPathElts.def +++ b/lib/Sema/ConstraintLocatorPathElts.def @@ -41,6 +41,9 @@ /// Matching an argument to a parameter. CUSTOM_LOCATOR_PATH_ELT(ApplyArgToParam) +/// Argument label of function application. +CUSTOM_LOCATOR_PATH_ELT(ArgumentLabel) + /// The argument of function application. SIMPLE_LOCATOR_PATH_ELT(ApplyArgument) From 8c762ac96652baab96baa3810595aa934db8ea01 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 22:15:17 +0900 Subject: [PATCH 02/10] [ConstraintSystem] add diagnostic note message for candidates of ... callee overload which has label issue --- include/swift/AST/DiagnosticsSema.def | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index 02ae15baf0630..615222fa144b7 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -1136,8 +1136,14 @@ ERROR(argument_out_of_order_binary_op,none, "operator argument #%0 must precede operator argument #%1", (unsigned, unsigned)) NOTE(candidate_expected_different_labels,none, - "incorrect labels for candidate (have: '%0', expected: '%1')", - (StringRef, StringRef)) + "incorrect label%select{|s}0 for candidate (have: '%1', expected: '%2')", + (bool, StringRef, StringRef)) +NOTE(candidate_expected_unlabeled,none, + "extraneous label%select{|s}0 '%1' for candidate unnamed parameter%select{|s}0", + (bool, StringRef)) +NOTE(candidate_expected_labeled,none, + "missing label%select{|s}0 for candidate parameter%select{|s}0 '%1'", + (bool, StringRef)) ERROR(member_shadows_function,none, "use of %0 refers to %1 rather than %2 %3", From 3f6119d8002c460783ae23a0a895046792725539 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:04:32 +0900 Subject: [PATCH 03/10] [ConstraintSystem] change `RelabelArguments` fix to `RelabelArgument` ... which represents just a one label error --- lib/Sema/CSFix.h | 64 ++++++++++++++++++++++------------------- lib/Sema/CSSimplify.cpp | 20 ++++++++----- 2 files changed, 47 insertions(+), 37 deletions(-) diff --git a/lib/Sema/CSFix.h b/lib/Sema/CSFix.h index ad3b45633bc70..36a96340d6058 100644 --- a/lib/Sema/CSFix.h +++ b/lib/Sema/CSFix.h @@ -73,9 +73,11 @@ enum class FixKind : uint8_t { /// Mark function type as explicitly '@escaping'. ExplicitlyEscaping, - /// Arguments have labeling failures - missing/extraneous or incorrect - /// labels attached to the, fix it by suggesting proper labels. - RelabelArguments, + /// Labeling failure associated with a particular argument, could be a + /// missing, extraneous or incorrect label. + /// Let fix the problem by suggesting a new label aligned with parameter at + /// the same position. + RelabelArgument, /// Treat rvalue as lvalue TreatRValueAsLValue, @@ -372,41 +374,43 @@ class TreatRValueAsLValue final : public ConstraintFix { ConstraintLocator *locator); }; -/// Arguments have labeling failures - missing/extraneous or incorrect -/// labels attached to the, fix it by suggesting proper labels. -class RelabelArguments final - : public ConstraintFix, - private llvm::TrailingObjects { - friend TrailingObjects; +/// Labeling failure associated with a particular argument, could be a missing, +/// extraneous or incorrect label. Let fix the problem by suggesting a new label +/// aligned with parameter at the same position. +class RelabelArgument final : public ConstraintFix { + using ParamBinding = SmallVector; - unsigned NumLabels; + Identifier ArgLabel; + SourceLoc ArgLabelLoc; + SourceLoc ArgLoc; + Identifier ParamLabel; - RelabelArguments(ConstraintSystem &cs, - llvm::ArrayRef correctLabels, - ConstraintLocator *locator) - : ConstraintFix(cs, FixKind::RelabelArguments, locator), - NumLabels(correctLabels.size()) { - std::uninitialized_copy(correctLabels.begin(), correctLabels.end(), - getLabelsBuffer().begin()); - } + SmallVector Bindings; -public: - std::string getName() const override { return "re-label argument(s)"; } + RelabelArgument(ConstraintSystem &cs, Identifier argLabel, + SourceLoc argLabelLoc, SourceLoc argLoc, + Identifier paramLabel, ArrayRef bindings, + ConstraintLocator *locator) + : ConstraintFix(cs, FixKind::RelabelArgument, locator), + ArgLabel(argLabel), ArgLabelLoc(argLabelLoc), ArgLoc(argLoc), + ParamLabel(paramLabel), Bindings(bindings.begin(), bindings.end()) {} - ArrayRef getLabels() const { - return {getTrailingObjects(), NumLabels}; - } +public: + std::string getName() const override { return "re-label argument"; } bool diagnose(const Solution &solution, bool asNote = false) const override; - static RelabelArguments *create(ConstraintSystem &cs, - llvm::ArrayRef correctLabels, - ConstraintLocator *locator); + Identifier getArgLabel() const { return ArgLabel; } + SourceLoc getArgLabelLoc() const { return ArgLabelLoc; } + SourceLoc getArgLoc() const { return ArgLoc; } + Identifier getParamLabel() const { return ParamLabel; } + ArrayRef getBindings() const { return Bindings; } -private: - MutableArrayRef getLabelsBuffer() { - return {getTrailingObjects(), NumLabels}; - } + static RelabelArgument *create(ConstraintSystem &cs, Identifier argLabel, + SourceLoc argLabelLoc, SourceLoc argLoc, + Identifier paramLabel, + ArrayRef bindings, + ConstraintLocator *locator); }; /// Add a new conformance to the type to satisfy a requirement. diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index b8b54d33893c5..a5f53e53540c4 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -1975,12 +1975,18 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2, } if (hasLabelingFailures) { - SmallVector correctLabels; - for (const auto ¶m : func2Params) - correctLabels.push_back(param.getLabel()); - - auto *fix = RelabelArguments::create(*this, correctLabels, - getConstraintLocator(argumentLocator)); + // FIXME: This code doesn't work correctly. + // Previously `RelabelArguments` takes locator as source of arguments + // and pass it to `LabelingFailure` to diagnose. + // But `argumentLocator` is `DeclRef -> contextual type -> function + // argument` here. So `LabelingFailure::diagnoseAsError` failed + // `getArgumentListExprFor` and it didn't diagnose anything. + // When I remove `RelabelArguments`, + // I make empty `RelabelArgument` to just keep behavior. + + auto *fix = RelabelArgument::create( + *this, Identifier(), SourceLoc(), SourceLoc(), Identifier(), + SmallVector(), getConstraintLocator(argumentLocator)); if (recordFix(fix)) return getTypeMatchFailure(argumentLocator); } @@ -9582,7 +9588,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint( case FixKind::UseSubscriptOperator: case FixKind::ExplicitlyEscaping: - case FixKind::RelabelArguments: + case FixKind::RelabelArgument: case FixKind::RemoveCall: case FixKind::RemoveUnwrap: case FixKind::DefineMemberBasedOnUse: From d106472bf6bb03c8b0741416ac27ff55835cecb7 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:13:30 +0900 Subject: [PATCH 04/10] [ConstraintSystem] change `LabelingFailure` to use `RelabelArgument` ... fixes. New dianostic building logic considers pairs of argument and parameter well in complex situation. --- lib/Sema/CSDiagnostics.cpp | 284 ++++++++++++++++++++++++++++++++----- lib/Sema/CSDiagnostics.h | 22 ++- 2 files changed, 271 insertions(+), 35 deletions(-) diff --git a/lib/Sema/CSDiagnostics.cpp b/lib/Sema/CSDiagnostics.cpp index aa02e10370837..b8404bdeb1bd6 100644 --- a/lib/Sema/CSDiagnostics.cpp +++ b/lib/Sema/CSDiagnostics.cpp @@ -32,6 +32,7 @@ #include "swift/AST/Stmt.h" #include "swift/AST/Types.h" #include "swift/Basic/SourceLoc.h" +#include "swift/Basic/StringExtras.h" #include "swift/Parse/Lexer.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/PointerUnion.h" @@ -740,52 +741,271 @@ bool GenericArgumentsMismatchFailure::diagnoseAsError() { return true; } -bool LabelingFailure::diagnoseAsError() { - auto *argExpr = getArgumentListExprFor(getLocator()); - if (!argExpr) - return false; +bool LabelingFailure::diagnoseAsError() { return diagnoseAsError(false); } - return diagnoseArgumentLabelError(getASTContext(), argExpr, CorrectLabels, - isExpr(getRawAnchor())); -} +bool LabelingFailure::diagnoseAsNote() { return diagnoseAsError(true); } + +bool LabelingFailure::diagnoseAsError(bool asNote) { + auto appendLabelStr = [](SmallString<16> &str, Identifier label) { + if (label.empty()) { + str += '_'; + } else { + str += label.str(); + } + str += ':'; + }; + + auto escapeLabel = [](Identifier label) -> SmallString<16> { + SmallString<16> str; + if (canBeArgumentLabel(label.str())) { + return label.str(); + } + + str += "`"; + str += label.str(); + str += "`"; + return str; + }; + + auto addFixIts = [&](InFlightDiagnostic diag) { + for (const auto *fix : RelabelFixes) { + const auto argLabel = fix->getArgLabel(); + const auto paramLabel = fix->getParamLabel(); + + if (paramLabel.empty()) { + diag.fixItRemoveChars(fix->getArgLabelLoc(), fix->getArgLoc()); + } else { + auto str = escapeLabel(paramLabel); + if (argLabel.empty()) { + str += ": "; + diag.fixItInsert(fix->getArgLoc(), str); + } else { + diag.fixItReplace(fix->getArgLabelLoc(), str); + } + } + } + }; + + IsComplex = false; + + ASTNode callExpr = getLocator()->getAnchor(); + if (!callExpr) + return false; -bool LabelingFailure::diagnoseAsNote() { auto *argExpr = getArgumentListExprFor(getLocator()); if (!argExpr) return false; - SmallVector argLabels; - if (isa(argExpr)) { - argLabels.push_back(Identifier()); - } else if (auto *tuple = dyn_cast(argExpr)) { - argLabels.append(tuple->getElementNames().begin(), - tuple->getElementNames().end()); - } else { - return false; + SmallString<16> missingsStr; + SmallString<16> extrasStr; + + unsigned numMissing = 0; + unsigned numExtra = 0; + unsigned numWrong = 0; + unsigned numErrorKinds = 0; + + for (const auto *fix : RelabelFixes) { + const auto argLabel = fix->getArgLabel(); + const auto paramLabel = fix->getParamLabel(); + + if (argLabel != paramLabel) { + if (argLabel.empty()) { + numMissing++; + appendLabelStr(missingsStr, paramLabel); + } else if (paramLabel.empty()) { + numExtra++; + appendLabelStr(extrasStr, argLabel); + } else { + numWrong++; + } + } + } + + if (numWrong > 0) + numErrorKinds++; + if (numMissing > 0) + numErrorKinds++; + if (numExtra > 0) + numErrorKinds++; + if (NumOutOfOrder > 0) + numErrorKinds++; + + if (numErrorKinds >= 2 || numWrong >= 2) { + IsComplex = true; } - auto stringifyLabels = [](ArrayRef labels) -> std::string { - std::string str; - for (auto label : labels) { - str += label.empty() ? "_" : label.str(); - str += ':'; + bool plural = (numMissing + numExtra + numWrong) > 1; + bool isSubscript = isExpr(callExpr); + + SourceLoc diagLoc = argExpr->getLoc(); + + if (numMissing + numExtra + numWrong == 1) { + const auto *fix = RelabelFixes.front(); + + if (numMissing == 1) { + diagLoc = fix->getArgLoc(); + } else { + diagLoc = fix->getArgLabelLoc(); } - return "(" + str + ")"; - }; + } - auto selectedOverload = getCalleeOverloadChoiceIfAvailable(getLocator()); - if (!selectedOverload) + ConstraintLocator *calleeLocator = + getSolution().getCalleeLocator(getLocator()); + if (!calleeLocator) return false; - const auto &choice = selectedOverload->choice; - if (auto *decl = choice.getDeclOrNull()) { - emitDiagnosticAt(decl, diag::candidate_expected_different_labels, - stringifyLabels(argLabels), - stringifyLabels(CorrectLabels)); - return true; + Decl *calleeDecl = nullptr; + ParameterList *calleeParamList; + SmallVector calleeParams; + + Optional calleeChoice = + getOverloadChoiceIfAvailable(calleeLocator); + if (calleeChoice) { + calleeDecl = calleeChoice->choice.getDeclOrNull(); + + if (auto valueDecl = dyn_cast_or_null(calleeDecl)) { + if (auto paramList = getParameterList(valueDecl)) { + calleeParamList = paramList; + paramList->getParams(calleeParams); + } + } + } + /// If callee is an expression which has function type, there is no decl. + /// ```swift + /// func f() -> (Int) -> Void { + /// return { (a) in } + /// } + /// f()(a: 3) + /// ``` + + if (!calleeDecl) { + // ObjectLiteralExpr doesn't have resolved overload. + if (auto objLit = + getAsExpr(calleeLocator->getAnchor())) { + auto paramType = getCalleeParamTypeForObjectLiteralExpr(objLit); + if (paramType) { + AnyFunctionType::decomposeInput(paramType, calleeParams); + } + } } - return false; + if (IsComplex || numWrong > 0 || (numMissing > 0 && numExtra > 0)) { + SmallString<16> haveStr; + SmallString<16> expectedStr; + + if (IsComplex || plural) { + // in aggregated case, report all labels. + + ArrayRef Bindings = RelabelFixes.front()->getBindings(); + + SmallVector, 4> argToParamMap; + for (auto paramIdx : indices(Bindings)) { + if (Bindings[paramIdx].empty()) + continue; + unsigned argIdx = Bindings[paramIdx].front(); + if (argToParamMap.size() <= argIdx) + argToParamMap.resize(argIdx + 1); + argToParamMap[argIdx] = paramIdx; + } + + TupleExpr *tupleExpr = dyn_cast(argExpr); + if (tupleExpr) { + for (unsigned argIdx = 0; argIdx < tupleExpr->getNumElements();) { + // trailing closure + if (tupleExpr->hasTrailingClosure() && + argIdx + 1 == tupleExpr->getNumElements()) { + if (auto paramIdx = argToParamMap[argIdx]) { + // treat label of trailing closure as same with parameter. + appendLabelStr(haveStr, calleeParams[*paramIdx].getLabel()); + } + + argIdx++; + continue; + } + + appendLabelStr(haveStr, tupleExpr->getElementName(argIdx)); + + if (auto paramIdx = argToParamMap[argIdx]) { + if (Bindings[*paramIdx].size() > 1) { + // skip variadic tails + argIdx += Bindings[*paramIdx].size(); + continue; + } + } + + argIdx++; + } + } else if (ParenExpr *parenExpr = dyn_cast(argExpr)) { + appendLabelStr(haveStr, Identifier()); + } + + for (auto paramIdx : indices(calleeParams)) { + auto param = calleeParams[paramIdx]; + + if (Bindings[paramIdx].empty()) { + if (param.isVariadic() || + (calleeParamList && + calleeParamList->get(paramIdx)->isDefaultArgument())) { + // skip omitted optional parameter + continue; + } + } + + appendLabelStr(expectedStr, param.getLabel()); + } + } else { + for (const auto *fix : RelabelFixes) { + appendLabelStr(haveStr, fix->getArgLabel()); + appendLabelStr(expectedStr, fix->getParamLabel()); + } + } + + if (asNote) { + emitDiagnosticAt(calleeDecl, diag::candidate_expected_different_labels, + plural, haveStr, expectedStr); + } else { + auto diag = emitDiagnosticAt(diagLoc, diag::wrong_argument_labels, plural, + haveStr, expectedStr, isSubscript); + if (!IsComplex) { + addFixIts(std::move(diag)); + } + } + } else if (numMissing > 0) { + if (asNote) { + emitDiagnosticAt(calleeDecl, diag::candidate_expected_labeled, plural, + missingsStr); + } else { + addFixIts(emitDiagnosticAt(diagLoc, diag::missing_argument_labels, plural, + missingsStr, isSubscript)); + } + } else { + assert(numExtra > 0); + if (asNote) { + emitDiagnosticAt(calleeDecl, diag::candidate_expected_unlabeled, plural, + extrasStr); + } else { + addFixIts(emitDiagnosticAt(diagLoc, diag::extra_argument_labels, plural, + extrasStr, isSubscript)); + } + } + + return true; +} + +Type LabelingFailure::getCalleeParamTypeForObjectLiteralExpr( + ObjectLiteralExpr *expr) const { + auto protocol = TypeChecker::getLiteralProtocol(getASTContext(), expr); + if (!protocol) + return nullptr; + auto ctorName = + TypeChecker::getObjectLiteralConstructorName(getASTContext(), expr); + if (!ctorName) + return nullptr; + auto ctorDecl = dyn_cast_or_null( + protocol->getSingleRequirement(ctorName)); + if (!ctorDecl) + return nullptr; + return TypeChecker::getObjectLiteralParameterType(expr, ctorDecl); } bool NoEscapeFuncToTypeConversionFailure::diagnoseAsError() { diff --git a/lib/Sema/CSDiagnostics.h b/lib/Sema/CSDiagnostics.h index 72670b9f3fd4e..c43bc1537d71e 100644 --- a/lib/Sema/CSDiagnostics.h +++ b/lib/Sema/CSDiagnostics.h @@ -465,15 +465,31 @@ class SuperclassRequirementFailure final : public RequirementFailure { /// Call to `foo` is going to be diagnosed as missing `q:` /// and having extraneous `a:` labels, with appropriate fix-its added. class LabelingFailure final : public FailureDiagnostic { - ArrayRef CorrectLabels; + using ParamBinding = SmallVector; + + SmallVector RelabelFixes; + unsigned NumOutOfOrder; + + // computed in diagnose + bool IsComplex; public: LabelingFailure(const Solution &solution, ConstraintLocator *locator, - ArrayRef labels) - : FailureDiagnostic(solution, locator), CorrectLabels(labels) {} + ArrayRef relabelFixes, + unsigned numOutOfOrder) + : FailureDiagnostic(solution, locator), + RelabelFixes(relabelFixes.begin(), relabelFixes.end()), + NumOutOfOrder(numOutOfOrder), IsComplex(false) {} + + bool isComplex() const { return IsComplex; } bool diagnoseAsError() override; bool diagnoseAsNote() override; + +private: + bool diagnoseAsError(bool asNote); + + Type getCalleeParamTypeForObjectLiteralExpr(ObjectLiteralExpr *expr) const; }; /// Diagnose failures related to attempting member access on optional base From 8daace29dd32115fb86ffb5d349eaee56ea7570e Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:25:25 +0900 Subject: [PATCH 05/10] [ConstraintSystem] gather label fixes and build `LabelingFailure` ... from them. --- lib/Sema/CSFix.cpp | 148 ++++++++++++++++++++++++++++++++++++++++----- lib/Sema/CSFix.h | 27 ++++++++- 2 files changed, 158 insertions(+), 17 deletions(-) diff --git a/lib/Sema/CSFix.cpp b/lib/Sema/CSFix.cpp index 55438f3440153..ef26eb23f36b4 100644 --- a/lib/Sema/CSFix.cpp +++ b/lib/Sema/CSFix.cpp @@ -179,18 +179,134 @@ MarkExplicitlyEscaping::create(ConstraintSystem &cs, Type lhs, Type rhs, return new (cs.getAllocator()) MarkExplicitlyEscaping(cs, lhs, rhs, locator); } -bool RelabelArguments::diagnose(const Solution &solution, bool asNote) const { - LabelingFailure failure(solution, getLocator(), getLabels()); - return failure.diagnose(asNote); +// Find RelabelArgument and MoveOutOfOrder fixes. +// Result is sorted by priority for emitting aggregated diagnostics. +static void +findLabelingFixes(const Solution &solution, ASTNode applyAnchor, + SmallVectorImpl &foundFixes) { + auto checkLocatorPrefix = [&](ConstraintLocator *locator) -> bool { + if (locator->getAnchor() != applyAnchor) + return false; + + if (locator->getPath().size() < 1) + return false; + + for (auto element : locator->getPath()) { + if (element.getKind() == ConstraintLocator::ApplyArgument) { + return true; + } + } + return false; + }; + + for (auto *checkFix : solution.Fixes) { + if (!checkLocatorPrefix(checkFix->getLocator())) + continue; + + if (auto *fix = checkFix->getAs()) { + foundFixes.push_back(fix); + continue; + } + if (auto *fix = checkFix->getAs()) { + foundFixes.push_back(fix); + continue; + } + } + + auto typePriority = [](const ConstraintFix *csFix) -> int { + if (auto *fix = csFix->getAs()) + return 2; + if (auto *fix = csFix->getAs()) + return 1; + return 0; + }; + + auto getArgIdx = [](ConstraintLocator *loc) -> unsigned { + if (loc->getPath().empty()) + return 0; + auto element = loc->getPath().back(); + if (auto elem = element.getAs()) { + return elem->getArgIdx(); + } + return 0; + }; + + auto compare = [&](const ConstraintFix *a, const ConstraintFix *b) -> bool { + auto ap = typePriority(a); + auto bp = typePriority(b); + if (ap != bp) + return ap < bp; + auto aa = getArgIdx(a->getLocator()); + auto ba = getArgIdx(b->getLocator()); + return aa < ba; + }; + + llvm::sort(foundFixes, compare); } -RelabelArguments * -RelabelArguments::create(ConstraintSystem &cs, - llvm::ArrayRef correctLabels, - ConstraintLocator *locator) { - unsigned size = totalSizeToAlloc(correctLabels.size()); - void *mem = cs.getAllocator().Allocate(size, alignof(RelabelArguments)); - return new (mem) RelabelArguments(cs, correctLabels, locator); +static bool diagnoseLabelError(const ConstraintFix *thisFix, + ArrayRef fixes, + const Solution &solution, + ConstraintLocator *locator, + ArrayRef bindings, bool asNote) { + if (fixes.empty()) + return false; + if (thisFix != fixes.front()) + return false; + + SmallVector relabelFixes; + SmallVector oooFixes; + + for (auto *checkFix : fixes) { + if (auto *fix = checkFix->getAs()) { + relabelFixes.push_back(fix); + } else if (auto *fix = checkFix->getAs()) { + oooFixes.push_back(fix); + } + } + + bool isDiagnosed = false; + + if (!relabelFixes.empty()) { + LabelingFailure failure(solution, locator, relabelFixes, oooFixes.size()); + + if (failure.diagnose(asNote)) { + isDiagnosed = true; + + // In complex case, aggregated dianostic is emitted. + // It includes out of ordered label diagnostics. + // So it doesn't output more. + if (failure.isComplex()) { + return true; + } + } + } + + for (auto *fix : oooFixes) { + OutOfOrderArgumentFailure failure(solution, fix->getArgIdx(), + fix->getPrevArgIdx(), bindings, locator); + isDiagnosed = failure.diagnose(asNote) || isDiagnosed; + } + + return isDiagnosed; +} + +bool RelabelArgument::coalesceAndDiagnose( + const Solution &solution, ArrayRef secondaryFixes, + bool asNote) const { + SmallVector fixes; + findLabelingFixes(solution, getLocator()->getAnchor(), fixes); + return diagnoseLabelError(this, fixes, solution, getLocator(), Bindings, + asNote); +} + +RelabelArgument * +RelabelArgument::create(ConstraintSystem &cs, Identifier argLabel, + SourceLoc argLabelLoc, SourceLoc argLoc, + Identifier paramLabel, ArrayRef bindings, + ConstraintLocator *locator) { + return new (cs.getAllocator()) RelabelArgument( + cs, argLabel, argLabelLoc, argLoc, paramLabel, bindings, locator); } bool MissingConformance::diagnose(const Solution &solution, bool asNote) const { @@ -692,11 +808,13 @@ RemoveExtraneousArguments *RemoveExtraneousArguments::create( RemoveExtraneousArguments(cs, contextualType, extraArgs, locator); } -bool MoveOutOfOrderArgument::diagnose(const Solution &solution, - bool asNote) const { - OutOfOrderArgumentFailure failure(solution, ArgIdx, PrevArgIdx, Bindings, - getLocator()); - return failure.diagnose(asNote); +bool MoveOutOfOrderArgument::coalesceAndDiagnose( + const Solution &solution, ArrayRef secondaryFixes, + bool asNote) const { + SmallVector fixes; + findLabelingFixes(solution, getLocator()->getAnchor(), fixes); + return diagnoseLabelError(this, fixes, solution, getLocator(), Bindings, + asNote); } MoveOutOfOrderArgument *MoveOutOfOrderArgument::create( diff --git a/lib/Sema/CSFix.h b/lib/Sema/CSFix.h index 36a96340d6058..20cbf299a9b29 100644 --- a/lib/Sema/CSFix.h +++ b/lib/Sema/CSFix.h @@ -396,9 +396,19 @@ class RelabelArgument final : public ConstraintFix { ParamLabel(paramLabel), Bindings(bindings.begin(), bindings.end()) {} public: + static bool classof(const ConstraintFix *fix) { + return fix->getKind() == FixKind::RelabelArgument; + } + std::string getName() const override { return "re-label argument"; } - bool diagnose(const Solution &solution, bool asNote = false) const override; + bool coalesceAndDiagnose(const Solution &solution, + ArrayRef secondaryFixes, + bool asNote = false) const override; + + bool diagnose(const Solution &solution, bool asNote = false) const override { + return coalesceAndDiagnose(solution, ArrayRef(), asNote); + } Identifier getArgLabel() const { return ArgLabel; } SourceLoc getArgLabelLoc() const { return ArgLabelLoc; } @@ -1233,11 +1243,24 @@ class MoveOutOfOrderArgument final : public ConstraintFix { Bindings(bindings.begin(), bindings.end()) {} public: + static bool classof(const ConstraintFix *fix) { + return fix->getKind() == FixKind::MoveOutOfOrderArgument; + } + std::string getName() const override { return "move out-of-order argument to correct position"; } - bool diagnose(const Solution &solution, bool asNote = false) const override; + bool coalesceAndDiagnose(const Solution &solution, + ArrayRef secondaryFixes, + bool asNote = false) const override; + + bool diagnose(const Solution &solution, bool asNote = false) const override { + return coalesceAndDiagnose(solution, ArrayRef(), asNote); + } + + unsigned getArgIdx() const { return ArgIdx; } + unsigned getPrevArgIdx() const { return PrevArgIdx; } static MoveOutOfOrderArgument *create(ConstraintSystem &cs, unsigned argIdx, From 92a05806cba2a63e9761b29c18467ed5e22d10df Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:38:20 +0900 Subject: [PATCH 06/10] [ConstraintSystem] change `MatchCallArgumentListener` to build ... `RelabelArgument` for each label issues. --- lib/Sema/CSSimplify.cpp | 140 +++++++++++++++++------------------- lib/Sema/ConstraintSystem.h | 22 +++--- 2 files changed, 75 insertions(+), 87 deletions(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index a5f53e53540c4..8dcc01dd8676f 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -43,20 +43,21 @@ MatchCallArgumentListener::missingArgument(unsigned paramIdx) { return None; } -bool MatchCallArgumentListener::missingLabel(unsigned paramIdx) { return true; } -bool MatchCallArgumentListener::extraneousLabel(unsigned paramIdx) { +bool MatchCallArgumentListener::missingLabel(unsigned argIdx, + unsigned paramIdx) { return true; } -bool MatchCallArgumentListener::incorrectLabel(unsigned paramIdx) { +bool MatchCallArgumentListener::extraneousLabel(unsigned argIdx, + unsigned paramIdx) { return true; } - -bool MatchCallArgumentListener::outOfOrderArgument(unsigned argIdx, - unsigned prevArgIdx) { +bool MatchCallArgumentListener::incorrectLabel(unsigned argIdx, + unsigned paramIdx) { return true; } -bool MatchCallArgumentListener::relabelArguments(ArrayRef newNames){ +bool MatchCallArgumentListener::outOfOrderArgument(unsigned argIdx, + unsigned prevArgIdx) { return true; } @@ -904,38 +905,7 @@ class ArgumentFailureTracker : public MatchCallArgumentListener { return false; } - bool missingLabel(unsigned paramIndex) override { - return !CS.shouldAttemptFixes(); - } - - bool extraneousLabel(unsigned paramIndex) override { - return !CS.shouldAttemptFixes(); - } - - bool incorrectLabel(unsigned paramIndex) override { - return !CS.shouldAttemptFixes(); - } - - bool outOfOrderArgument(unsigned argIdx, unsigned prevArgIdx) override { - if (CS.shouldAttemptFixes()) { - // If some of the arguments are missing/extraneous, no reason to - // record a fix for this, increase the score so there is a way - // to identify that there is something going on besides just missing - // arguments. - if (!MissingArguments.empty() || !ExtraArguments.empty()) { - CS.increaseScore(SK_Fix); - return false; - } - - auto *fix = MoveOutOfOrderArgument::create( - CS, argIdx, prevArgIdx, Bindings, CS.getConstraintLocator(Locator)); - return CS.recordFix(fix); - } - - return true; - } - - bool relabelArguments(ArrayRef newLabels) override { + bool incorrectLabel(unsigned argIdx, unsigned paramIdx, unsigned impact) { if (!CS.shouldAttemptFixes()) return true; @@ -948,51 +918,71 @@ class ArgumentFailureTracker : public MatchCallArgumentListener { return false; } - auto anchor = Locator.getBaseLocator()->getAnchor(); - if (!anchor) + auto *locator = CS.getConstraintLocator(Locator); + + ASTNode callExpr = locator->getAnchor(); + if (!callExpr) return true; - unsigned numExtraneous = 0; - unsigned numRenames = 0; - unsigned numOutOfOrder = 0; + auto locatorExpr = simplifyLocatorToAnchor(locator); + TupleExpr *tupleExpr = getAsExpr(locatorExpr); + ParenExpr *parenExpr = getAsExpr(locatorExpr); + if (!tupleExpr && !parenExpr) + return true; - for (unsigned i : indices(newLabels)) { - // It's already known how many arguments are missing, - // it would be accounted for in the impact. - if (i >= Arguments.size()) - continue; + const auto argLabel = Arguments[argIdx].getLabel(); + SourceLoc argLabelLoc; + SourceLoc argLoc; + if (tupleExpr && (argIdx < tupleExpr->getNumElements())) { + argLabelLoc = tupleExpr->getElementNameLoc(argIdx); + argLoc = tupleExpr->getElement(argIdx)->getLoc(); + } + if (parenExpr) { + argLoc = parenExpr->getSubExpr()->getLoc(); + } - auto argLabel = Arguments[i].getLabel(); - auto paramLabel = newLabels[i]; + const auto paramLabel = Parameters[paramIdx].getLabel(); - if (argLabel == paramLabel) - continue; + auto *labelLocator = CS.getConstraintLocator( + Locator.withPathElement(LocatorPathElt::ArgumentLabel(argIdx))); - if (!argLabel.empty()) { - // Instead of this being a label mismatch which requires - // re-labeling, this could be an out-of-order argument - // instead which has a completely different impact. - if (llvm::count(newLabels, argLabel) == 1) { - ++numOutOfOrder; - } else if (paramLabel.empty()) { - ++numExtraneous; - } else { - ++numRenames; - } + auto *fix = RelabelArgument::create(CS, argLabel, argLabelLoc, argLoc, + paramLabel, Bindings, labelLocator); + return CS.recordFix(fix, impact); + } + + bool missingLabel(unsigned argIdx, unsigned paramIdx) override { + return incorrectLabel(argIdx, paramIdx, 1); + } + + bool extraneousLabel(unsigned argIdx, unsigned paramIdx) override { + return incorrectLabel(argIdx, paramIdx, 3); + } + + bool incorrectLabel(unsigned argIdx, unsigned paramIdx) override { + return incorrectLabel(argIdx, paramIdx, 4); + } + + bool outOfOrderArgument(unsigned argIdx, unsigned prevArgIdx) override { + if (CS.shouldAttemptFixes()) { + // If some of the arguments are missing/extraneous, no reason to + // record a fix for this, increase the score so there is a way + // to identify that there is something going on besides just missing + // arguments. + if (!MissingArguments.empty() || !ExtraArguments.empty()) { + CS.increaseScore(SK_Fix); + return false; } + + auto *labelLocator = CS.getConstraintLocator( + Locator.withPathElement(LocatorPathElt::ArgumentLabel(argIdx))); + + auto *fix = MoveOutOfOrderArgument::create(CS, argIdx, prevArgIdx, + Bindings, labelLocator); + return CS.recordFix(fix); } - auto *locator = CS.getConstraintLocator(Locator); - auto *fix = RelabelArguments::create(CS, newLabels, locator); - // Re-labeling fixes with extraneous/incorrect labels should be - // lower priority vs. other fixes on same/different overload(s) - // where labels did line up correctly. - // - // If there are not only labeling problems but also some of the - // arguments are missing, let's account of that in the impact. - auto impact = 1 + numOutOfOrder + numExtraneous * 2 + numRenames * 3 + - MissingArguments.size() * 2; - return CS.recordFix(fix, impact); + return true; } bool trailingClosureMismatch(unsigned paramIdx, unsigned argIdx) override { diff --git a/lib/Sema/ConstraintSystem.h b/lib/Sema/ConstraintSystem.h index 28b68e4779354..c9fcada435730 100644 --- a/lib/Sema/ConstraintSystem.h +++ b/lib/Sema/ConstraintSystem.h @@ -4870,27 +4870,31 @@ class MatchCallArgumentListener { /// Indicate that there was no label given when one was expected by parameter. /// - /// \param paramIndex The index of the parameter that is missing a label. + /// \param argIdx The index of the argument that is missing a label; + /// \param paramIdx The index of the parameter that has expected label. /// /// \returns true to indicate that this should cause a failure, false /// otherwise. - virtual bool missingLabel(unsigned paramIndex); + virtual bool missingLabel(unsigned argIdx, unsigned paramIdx); /// Indicate that there was label given when none was expected by parameter. /// - /// \param paramIndex The index of the parameter that wasn't expecting a label. + /// \param argIdx The index of the argument that has an unexpected extraneous + /// label; \param paramIdx The index of the parameter that wasn't expecting a + /// label. /// /// \returns true to indicate that this should cause a failure, false /// otherwise. - virtual bool extraneousLabel(unsigned paramIndex); + virtual bool extraneousLabel(unsigned argIdx, unsigned paramIdx); /// Indicate that there was a label given with a typo(s) in it. /// - /// \param paramIndex The index of the parameter with misspelled label. + /// \param argIdx The index of the argument with misspelled label. + /// \param paramIdx The index of the parameter that has expected label. /// /// \returns true to indicate that this should cause a failure, false /// otherwise. - virtual bool incorrectLabel(unsigned paramIndex); + virtual bool incorrectLabel(unsigned argIdx, unsigned paramIdx); /// Indicates that an argument is out-of-order with respect to a previously- /// seen argument. @@ -4902,12 +4906,6 @@ class MatchCallArgumentListener { /// otherwise. virtual bool outOfOrderArgument(unsigned argIdx, unsigned prevArgIdx); - /// Indicates that the arguments need to be relabeled to match the parameters. - /// - /// \returns true to indicate that this should cause a failure, false - /// otherwise. - virtual bool relabelArguments(ArrayRef newNames); - /// Indicates that the trailing closure argument at the given \c argIdx /// cannot be passed to the last parameter at \c paramIdx. /// From 8e6e9636f54358b96e6cd46a98174225bf34731e Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:44:41 +0900 Subject: [PATCH 07/10] [ConstraintSystem] implement new logic of reporting label ... issues in `matchCallArguments`. It finds all of out of order label matchings. It reports label issues individually. --- lib/Sema/CSSimplify.cpp | 162 +++++++++++++--------------------------- 1 file changed, 52 insertions(+), 110 deletions(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index 8dcc01dd8676f..c2e956bfcd61e 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -716,132 +716,74 @@ matchCallArguments(SmallVectorImpl &args, // If any arguments were provided out-of-order, check whether we have // violated any of the reordering rules. if (potentiallyOutOfOrder) { - // If we've seen label failures and now there is an out-of-order - // parameter (or even worse - OoO parameter with label re-naming), - // we most likely have no idea what would be the best - // diagnostic for this situation, so let's just try to re-label. - auto isOutOfOrderArgument = [&](unsigned toParamIdx, unsigned fromArgIdx, - unsigned toArgIdx) { - if (fromArgIdx <= toArgIdx) { - return false; - } - - auto newLabel = args[fromArgIdx].getLabel(); - auto oldLabel = args[toArgIdx].getLabel(); + // Fix all labeling failures. - if (newLabel != params[toParamIdx].getLabel()) { - return false; - } + auto isTrailingClosureArgument = [&](unsigned argIdx) -> bool { + return unlabeledTrailingClosureArgIndex.hasValue() && argIdx == numArgs - 1; + }; - auto paramIdx = toParamIdx + 1; - for (; paramIdx < params.size(); ++paramIdx) { - // Looks like new position (excluding defaulted parameters), - // has a valid label. - if (oldLabel == params[paramIdx].getLabel()) - break; + // Pick arguments mapped to some parameter. + // It' used for searching expected destination of label which is out of + // order. + SmallVector, 4> argBindings(args.size()); + for (auto paramIdx : indices(params)) { + if (parameterBindings[paramIdx].empty()) + continue; + const auto argIdx = parameterBindings[paramIdx].front(); + // Skip synthesized argument for missing argument + if (argIdx >= numArgs) + continue; - // If we are moving the the position with a different label - // and there is no default value for it, can't diagnose the - // problem as a simple re-ordering. - if (!paramInfo.hasDefaultArgument(paramIdx)) - return false; - } + argBindings[argIdx] = paramIdx; + } - // label was not found - if (paramIdx == params.size()) { - return false; - } + // Emit all label errors + for (const auto paramIdx : indices(params)) { + if (parameterBindings[paramIdx].empty()) + continue; - return true; - }; + // Skip synthesized argument for missing argument + const auto argIdx = parameterBindings[paramIdx].front(); + if (argIdx >= numArgs) + continue; - SmallVector paramToArgMap; - paramToArgMap.reserve(params.size()); - { - unsigned argIdx = 0; - for (const auto &binding : parameterBindings) { - paramToArgMap.push_back(argIdx); - argIdx += binding.size(); - } - } + // Trailing closure doesn't case label + if (isTrailingClosureArgument(argIdx)) + continue; - // Enumerate the parameters and their bindings to see if any arguments are - // our of order - bool hadLabelMismatch = false; - for (const auto paramIdx : indices(params)) { - const auto toArgIdx = paramToArgMap[paramIdx]; - const auto &binding = parameterBindings[paramIdx]; - for (const auto paramBindIdx : indices(binding)) { - // We've found the parameter that has an out of order - // argument, and know the indices of the argument that - // needs to move (fromArgIdx) and the argument location - // it should move to (toArgIdx). - const auto fromArgIdx = binding[paramBindIdx]; - - // Does nothing for variadic tail. - if (params[paramIdx].isVariadic() && paramBindIdx > 0) { - assert(args[fromArgIdx].getLabel().empty()); - continue; - } + const auto argLabel = args[argIdx].getLabel(); + const auto paramLabel = params[paramIdx].getLabel(); - // First let's double check if out-of-order argument is nothing - // more than a simple label mismatch, because in situation where - // one argument requires label and another one doesn't, but caller - // doesn't provide either, problem is going to be identified as - // out-of-order argument instead of label mismatch. - const auto expectedLabel = params[paramIdx].getLabel(); - const auto argumentLabel = args[fromArgIdx].getLabel(); - - if (argumentLabel != expectedLabel) { - // - The parameter is unnamed, in which case we try to fix the - // problem by removing the name. - if (expectedLabel.empty()) { - hadLabelMismatch = true; - if (listener.extraneousLabel(paramIdx)) - return true; - // - The argument is unnamed, in which case we try to fix the - // problem by adding the name. - } else if (argumentLabel.empty()) { - hadLabelMismatch = true; - if (listener.missingLabel(paramIdx)) - return true; - // - The argument label has a typo at the same position. - } else if (fromArgIdx == toArgIdx) { - hadLabelMismatch = true; - if (listener.incorrectLabel(paramIdx)) - return true; - } + if (argLabel != paramLabel) { + // emit label wrong/missing/extra + if (argLabel.empty()) { + if (listener.missingLabel(argIdx, paramIdx)) + return true; + } else if (paramLabel.empty()) { + if (listener.extraneousLabel(argIdx, paramIdx)) + return true; + } else { + if (listener.incorrectLabel(argIdx, paramIdx)) + return true; } + } - if (fromArgIdx == toArgIdx) { - // If the argument is in the right location, just continue + for (unsigned leftArgIdx = 0; leftArgIdx < argIdx; leftArgIdx++) { + const auto leftParamIdx = argBindings[leftArgIdx]; + if (!leftParamIdx) continue; - } - // This situation looks like out-of-order argument but it's hard - // to say exactly without considering other factors, because it - // could be invalid labeling too. - if (!hadLabelMismatch && - isOutOfOrderArgument(paramIdx, fromArgIdx, toArgIdx)) - return listener.outOfOrderArgument(fromArgIdx, toArgIdx); - - SmallVector expectedLabels; - llvm::transform(params, std::back_inserter(expectedLabels), - [](const AnyFunctionType::Param ¶m) { - return param.getLabel(); - }); - return listener.relabelArguments(expectedLabels); + if (paramIdx <= *leftParamIdx) { + // emit out of order + if (listener.outOfOrderArgument(argIdx, leftArgIdx)) + return true; + break; + } } } } - // If no arguments were renamed, the call arguments match up with the - // parameters. - if (actualArgNames.empty()) - return false; - - // The arguments were relabeled; notify the listener. - return listener.relabelArguments(actualArgNames); + return false; } class ArgumentFailureTracker : public MatchCallArgumentListener { From 37cc05fb1fe204b6cfda54534a58ac27b24a8b5d Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Wed, 20 May 2020 23:56:35 +0900 Subject: [PATCH 08/10] [ConstraintSystem] remove `actualArgNames` in `matchCallArguments` --- lib/Sema/CSSimplify.cpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index c2e956bfcd61e..b67aebb5fe13d 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -238,7 +238,6 @@ matchCallArguments(SmallVectorImpl &args, // Keep track of which arguments we have claimed from the argument tuple. unsigned numArgs = args.size(); SmallVector claimedArgs(numArgs, false); - SmallVector actualArgNames; unsigned numClaimedArgs = 0; // Indicates whether any of the arguments are potentially out-of-order, @@ -254,28 +253,6 @@ matchCallArguments(SmallVectorImpl &args, assert(argNumber != numArgs && "Must have a valid index to claim"); assert(!claimedArgs[argNumber] && "Argument already claimed"); - if (!actualArgNames.empty()) { - // We're recording argument names; record this one. - actualArgNames[argNumber] = expectedName; - } else if (args[argNumber].getLabel() != expectedName && !ignoreNameClash) { - // We have an argument name mismatch. Start recording argument names. - actualArgNames.resize(numArgs); - - // Figure out previous argument names from the parameter bindings. - for (auto i : indices(params)) { - const auto ¶m = params[i]; - bool firstArg = true; - - for (auto argIdx : parameterBindings[i]) { - actualArgNames[argIdx] = firstArg ? param.getLabel() : Identifier(); - firstArg = false; - } - } - - // Record this argument name. - actualArgNames[argNumber] = expectedName; - } - claimedArgs[argNumber] = true; ++numClaimedArgs; return argNumber; From e98c72b6181403c2cfef146aa4a516a2a10a99e6 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Thu, 21 May 2020 00:03:02 +0900 Subject: [PATCH 09/10] [ConstraintSystem] adjust matching position of unlabeled parameter ... by considering unbounded parameter which is at left of current parameter in `matchCallArgument`. It avoids matching which has unwanted crossing pairs between argument and parameter. It provides natural relabeling diagnostics without reconstructing aligned matching pairs when out of ordered mapping happens like old implementation. --- lib/Sema/CSSimplify.cpp | 56 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index b67aebb5fe13d..040b8c79a0767 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -267,6 +267,7 @@ matchCallArguments(SmallVectorImpl &args, // Local function that retrieves the next unclaimed argument with the given // name (which may be empty). This routine claims the argument. auto claimNextNamed = [&](unsigned &nextArgIdx, Identifier paramLabel, + Optional paramIdx, bool ignoreNameMismatch, bool forVariadic = false) -> Optional { // Skip over any claimed arguments. @@ -276,6 +277,47 @@ matchCallArguments(SmallVectorImpl &args, if (numClaimedArgs == numArgs) return None; + /// When we determine which argument is bound to unlabeled parameter, + /// consider still unbounded parameter which is prior to current parameter. + /// In order not to intersect binding position that remaining parameter will + /// bind later, skip a unlabeled argument as much as it can. + /// + /// For example: + /// @code + /// func f(aa: Int, _ bb: Int) {} + /// f(0, 1) + /// @endcode + /// Choice argument[1] for parameter[1] so that parameter[0] will be bounded + /// to argument[0] later. + /// + /// Because variadics parameter can be bounded with more than one arguments, + /// they don't this. + if (paramLabel.empty() && paramIdx && !forVariadic && + !params[*paramIdx].isVariadic()) { + unsigned unboundedParamCount = 0; + for (unsigned pi = 0; pi < *paramIdx; pi++) { + if (parameterBindings[pi].empty()) { + if (params[pi].isVariadic() || paramInfo.hasDefaultArgument(pi)) + continue; + + unboundedParamCount++; + } + } + + unsigned keepedArgCount = 0; + for (unsigned ai = nextArgIdx; ai < numArgs; ai++) { + if (claimedArgs[ai]) + continue; + + nextArgIdx = std::max(nextArgIdx, ai); + + if (keepedArgCount >= unboundedParamCount) { + break; + } + keepedArgCount++; + } + } + // Go hunting for an unclaimed argument whose name does match. Optional claimedWithSameName; for (unsigned i = nextArgIdx; i != numArgs; ++i) { @@ -368,8 +410,8 @@ matchCallArguments(SmallVectorImpl &args, // Handle variadic parameters. if (param.isVariadic()) { // Claim the next argument with the name of this parameter. - auto claimed = - claimNextNamed(nextArgIdx, param.getLabel(), ignoreNameMismatch); + auto claimed = claimNextNamed(nextArgIdx, param.getLabel(), paramIdx, + ignoreNameMismatch); // If there was no such argument, leave the parameter unfulfilled. if (!claimed) { @@ -390,8 +432,10 @@ matchCallArguments(SmallVectorImpl &args, { nextArgIdx = *claimed; // Claim any additional unnamed arguments. - while ( - (claimed = claimNextNamed(nextArgIdx, Identifier(), false, true))) { + while ((claimed = claimNextNamed( + nextArgIdx, /*paramLabel=*/Identifier(), /*paramIdx=*/None, + /*ignoreNameMismatch=*/false, + /*forVariadic=*/true))) { parameterBindings[paramIdx].push_back(*claimed); } } @@ -401,8 +445,8 @@ matchCallArguments(SmallVectorImpl &args, } // Try to claim an argument for this parameter. - if (auto claimed = - claimNextNamed(nextArgIdx, param.getLabel(), ignoreNameMismatch)) { + if (auto claimed = claimNextNamed(nextArgIdx, param.getLabel(), paramIdx, + ignoreNameMismatch)) { parameterBindings[paramIdx].push_back(*claimed); return; } From a9be9cfd79554bab4f6533ba87a0229d553768c0 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Sun, 24 May 2020 16:31:42 +0900 Subject: [PATCH 10/10] [ConstraintSystem][NFC] update tests for new individual labeling fixes --- .../objc_missing_designated_init.swift | 58 +++- test/ClangImporter/objc_parse.swift | 2 +- test/Constraints/argument_matching.swift | 298 ++++++++++-------- test/Constraints/diagnostics.swift | 4 +- test/Constraints/optional.swift | 4 +- test/Constraints/unchecked_optional.swift | 4 +- test/FixCode/verify-fixits.swift | 38 +-- test/FixCode/verify-fixits.swift.result | 38 +-- test/Frontend/verify-fixits.swift | 62 ++-- test/expr/unary/keypath/keypath.swift | 4 +- .../rdar45470505.swift | 2 +- 11 files changed, 288 insertions(+), 226 deletions(-) diff --git a/test/ClangImporter/objc_missing_designated_init.swift b/test/ClangImporter/objc_missing_designated_init.swift index 1cd5ff1f338de..2100e2f7eefe7 100644 --- a/test/ClangImporter/objc_missing_designated_init.swift +++ b/test/ClangImporter/objc_missing_designated_init.swift @@ -3,28 +3,66 @@ import UnimportableMembers import UnimportableMembersUser -class IncompleteInitSubclassImplicit : IncompleteDesignatedInitializers { // expected-note 6 {{incorrect labels for candidate}} +class IncompleteInitSubclassImplicit : IncompleteDesignatedInitializers { + // expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} + // expected-note@-2 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} + // expected-note@-3 {{incorrect label for candidate (have: 'conveniently:', expected: 'first:')}} + // expected-note@-4 {{incorrect label for candidate (have: 'conveniently:', expected: 'second:')}} + // expected-note@-5 {{incorrect label for candidate (have: 'category:', expected: 'first:')}} + // expected-note@-6 {{incorrect label for candidate (have: 'category:', expected: 'second:')}} var myOneNewMember = 1 } class IncompleteInitSubclass : IncompleteDesignatedInitializers { - override init(first: Int) {} // expected-note 3 {{incorrect labels for candidate}} - override init(second: Int) {} // expected-note 3 {{incorrect labels for candidate}} + override init(first: Int) {} + // expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} + // expected-note@-2 {{incorrect label for candidate (have: 'conveniently:', expected: 'first:')}} + // expected-note@-3 {{incorrect label for candidate (have: 'category:', expected: 'first:')}} + override init(second: Int) {} + // expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} + // expected-note@-2 {{incorrect label for candidate (have: 'conveniently:', expected: 'second:')}} + // expected-note@-3 {{incorrect label for candidate (have: 'category:', expected: 'second:')}} } -class IncompleteConvenienceInitSubclass : IncompleteConvenienceInitializers {} // expected-note 2 {{incorrect labels for candidate}} +class IncompleteConvenienceInitSubclass : IncompleteConvenienceInitializers {} +// expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} +// expected-note@-2 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} -class IncompleteUnknownInitSubclass : IncompleteUnknownInitializers {} // expected-note 4 {{incorrect labels for candidate}} +class IncompleteUnknownInitSubclass : IncompleteUnknownInitializers {} +// expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} +// expected-note@-2 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} +// expected-note@-3 {{incorrect label for candidate (have: 'missing:', expected: 'conveniently:')}} +// expected-note@-4 {{incorrect label for candidate (have: 'missing:', expected: 'category:')}} -class IncompleteInitCategorySubclassImplicit : IncompleteDesignatedInitializersWithCategory {} // expected-note 6 {{incorrect labels for candidate}} +class IncompleteInitCategorySubclassImplicit : IncompleteDesignatedInitializersWithCategory {} +// expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} +// expected-note@-2 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} +// expected-note@-3 {{incorrect label for candidate (have: 'conveniently:', expected: 'first:')}} +// expected-note@-4 {{incorrect label for candidate (have: 'conveniently:', expected: 'second:')}} +// expected-note@-5 {{incorrect label for candidate (have: 'category:', expected: 'first:')}} +// expected-note@-6 {{incorrect label for candidate (have: 'category:', expected: 'second:')}} class IncompleteInitCategorySubclass : IncompleteDesignatedInitializersWithCategory { - override init(first: Int) {} // expected-note 3 {{incorrect labels for candidate}} - override init(second: Int) {} // expected-note 3 {{incorrect labels for candidate}} + override init(first: Int) {} + // expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} + // expected-note@-2 {{incorrect label for candidate (have: 'conveniently:', expected: 'first:')}} + // expected-note@-3 {{incorrect label for candidate (have: 'category:', expected: 'first:')}} + override init(second: Int) {} + // expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} + // expected-note@-2 {{incorrect label for candidate (have: 'conveniently:', expected: 'second:')}} + // expected-note@-3 {{incorrect label for candidate (have: 'category:', expected: 'second:')}} } -class DesignatedInitializerInAnotherModuleSubclass : DesignatedInitializerInAnotherModule {} // expected-note 9 {{incorrect labels for candidate}} - +class DesignatedInitializerInAnotherModuleSubclass : DesignatedInitializerInAnotherModule {} +// expected-note@-1 {{incorrect label for candidate (have: 'missing:', expected: 'first:')}} +// expected-note@-2 {{incorrect label for candidate (have: 'missing:', expected: 'second:')}} +// expected-note@-3 {{incorrect label for candidate (have: 'missing:', expected: 'fromOtherModule:')}} +// expected-note@-4 {{incorrect label for candidate (have: 'conveniently:', expected: 'first:')}} +// expected-note@-5 {{incorrect label for candidate (have: 'conveniently:', expected: 'second:')}} +// expected-note@-6 {{incorrect label for candidate (have: 'conveniently:', expected: 'fromOtherModule:')}} +// expected-note@-7 {{incorrect label for candidate (have: 'category:', expected: 'first:')}} +// expected-note@-8 {{incorrect label for candidate (have: 'category:', expected: 'second:')}} +// expected-note@-9 {{incorrect label for candidate (have: 'category:', expected: 'fromOtherModule:')}} func testBaseClassesBehaveAsExpected() { _ = IncompleteDesignatedInitializers(first: 0) // okay diff --git a/test/ClangImporter/objc_parse.swift b/test/ClangImporter/objc_parse.swift index a39a815378b99..b990f65dc59b4 100644 --- a/test/ClangImporter/objc_parse.swift +++ b/test/ClangImporter/objc_parse.swift @@ -200,7 +200,7 @@ func testProtocols(_ b: B, bp: BProto) { var bp2 : BProto = b var b2 : B = bp // expected-error{{cannot convert value of type 'BProto' to specified type 'B'}} bp.method(1, with: 2.5 as Float) - bp.method(1, withFoo: 2.5) // expected-error{{incorrect argument label in call (have '_:withFoo:', expected '_:with:')}} + bp.method(1, withFoo: 2.5) // expected-error{{incorrect argument label in call (have 'withFoo:', expected 'with:')}} bp2 = b.getAsProto() var c1 : Cat1Proto = b diff --git a/test/Constraints/argument_matching.swift b/test/Constraints/argument_matching.swift index febabc64f094d..25679145efb57 100644 --- a/test/Constraints/argument_matching.swift +++ b/test/Constraints/argument_matching.swift @@ -47,7 +47,7 @@ X2(5).f2(5) func allkeywords1(x: Int, y: Int) { } // Missing keywords. -allkeywords1(1, 2) // expected-error{{missing argument labels}} {{14-14=x: }} {{17-17=y: }} +allkeywords1(1, 2) // expected-error{{missing argument labels 'x:y:' in call}} {{14-14=x: }} {{17-17=y: }} allkeywords1(x: 1, 2) // expected-error{{missing argument label 'y:' in call}} {{20-20=y: }} allkeywords1(1, y: 2) // expected-error{{missing argument label 'x:' in call}} {{14-14=x: }} @@ -71,7 +71,7 @@ secondArgumentNotLabeled(10, 20) // expected-error@-1 {{missing argument label 'a:' in call}} func f_31849281(x: Int, y: Int, z: Int) {} -f_31849281(42, y: 10, x: 20) // expected-error {{incorrect argument labels in call (have '_:y:x:', expected 'x:y:z:')}} {{12-12=x: }} {{23-24=z}} +f_31849281(42, y: 10, x: 20) // expected-error {{incorrect argument label in call (have '_:y:x:', expected 'x:y:z:')}} // ------------------------------------------- // Extraneous keywords @@ -87,27 +87,29 @@ func somekeywords1(_ x: Int, y: Int, z: Int) { } somekeywords1(x: 1, y: 2, z: 3) // expected-error{{extraneous argument label 'x:' in call}}{{15-18=}} somekeywords1(1, 2, 3) // expected-error{{missing argument labels 'y:z:' in call}}{{18-18=y: }}{{21-21=z: }} -somekeywords1(x: 1, 2, z: 3) // expected-error{{incorrect argument labels in call (have 'x:_:z:', expected '_:y:z:')}}{{15-18=}}{{21-21=y: }} +somekeywords1(x: 1, 2, z: 3) // expected-error{{incorrect argument label in call (have 'x:_:z:', expected '_:y:z:')}} {{none}} // SR-2242: poor diagnostic when argument label is omitted func r27212391(x: Int, _ y: Int) { + // expected-note@-1 {{candidate '(Int, Int) -> ()' requires 2 arguments, but 3 were provided}} let _: Int = x + y } func r27212391(a: Int, x: Int, _ y: Int) { + // expected-note@-1 {{candidate has partially matching parameter list (a: Int, x: Int, Int)}} let _: Int = a + x + y } r27212391(3, 5) // expected-error {{missing argument label 'x:' in call}} -r27212391(3, y: 5) // expected-error {{incorrect argument labels in call (have '_:y:', expected 'x:_:')}} +r27212391(3, y: 5) // expected-error {{incorrect argument label in call (have '_:y:', expected 'x:_:')}} r27212391(3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #1}} {{11-11=x: 5, }} {{12-18=}} -r27212391(y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'y:x:', expected 'x:_:')}} {{11-12=x}} {{17-20=}} -r27212391(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:_:', expected 'x:_:')}} +r27212391(y: 3, x: 5) // expected-error {{incorrect argument label in call (have 'y:x:', expected 'x:_:')}} +r27212391(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:', expected 'x:')}} r27212391(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}} -r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}} -r27212391(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}} -r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}} +r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument label in call (have 'a:_:y:', expected 'a:x:_:')}} +r27212391(1, x: 3, y: 5) // expected-error {{no exact matches in call to global function 'r27212391'}} +r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument label in call (have 'a:y:x:', expected 'a:x:_:')}} r27212391(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{17-17=x: 5, }} {{18-24=}} // ------------------------------------------- @@ -121,14 +123,20 @@ struct rdar31849281 { var foo, a, b, c: Int } _ = rdar31849281(a: 101, b: 102, c: 103, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} _ = rdar31849281(a: 101, c: 103, b: 102, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} +// expected-error@-1 {{argument 'b' must precede argument 'c'}} + _ = rdar31849281(foo: 104, a: 101, c: 103, b: 102) // expected-error {{argument 'b' must precede argument 'c'}} {{36-36=b: 102, }} {{42-50=}} -_ = rdar31849281(b: 102, c: 103, a: 101, foo: 104) // expected-error {{incorrect argument labels in call (have 'b:c:a:foo:', expected 'foo:a:b:c:')}} {{18-19=foo}} {{26-27=a}} {{34-35=b}} {{42-45=c}} +_ = rdar31849281(b: 102, c: 103, a: 101, foo: 104) // expected-error {{argument 'a' must precede argument 'b'}} {{32-40=}} {{18-18=a: 101, }} +// expected-error@-1 {{argument 'foo' must precede argument 'b'}} + _ = rdar31849281(foo: 104, b: 102, c: 103, a: 101) // expected-error {{argument 'a' must precede argument 'b'}} {{28-28=a: 101, }} {{42-50=}} func fun_31849281(a: (Bool) -> Bool, b: (Int) -> (String), c: [Int?]) {} fun_31849281(c: [nil, 42], a: { !$0 }, b: { (num: Int) -> String in return "\(num)" }) -// expected-error @-1 {{incorrect argument labels in call (have 'c:a:b:', expected 'a:b:c:')}} {{14-15=a}} {{28-29=b}} {{40-41=c}} +// expected-error @-1 {{argument 'a' must precede argument 'c'}} {{26-38=}} {{14-14=a: { !$0 \}, }} +// expected-error @-2 {{argument 'b' must precede argument 'c'}} + fun_31849281(a: { !$0 }, c: [nil, 42], b: { (num: Int) -> String in return String(describing: num) }) // expected-error @-1 {{argument 'b' must precede argument 'c'}} {{26-26=b: { (num: Int) -> String in return String(describing: num) }, }} {{38-101=}} fun_31849281(a: { !$0 }, c: [nil, 42], b: { "\($0)" }) @@ -138,9 +146,9 @@ struct ReorderAndAllLabels { func f(aa: Int, bb: Int, cc: Int, dd: Int) {} func test() { - f(bb: 1, ccx: 2, ddx: 3, aa: 0) // expected-error {{argument 'aa' must precede argument 'bb'}} {{28-35=}} {{7-7=aa: 0, }} {{none}} + f(bb: 1, ccx: 2, ddx: 3, aa: 0) // expected-error {{incorrect argument labels in call (have 'bb:ccx:ddx:aa:', expected 'aa:bb:cc:dd:')}} {{none}} - f(bbx: 1, ccx: 2, ddx: 3, aa: 0) // expected-error {{incorrect argument labels in call (have 'bbx:ccx:ddx:aa:', expected 'aa:bb:cc:dd:')}} {{7-10=aa}} {{15-18=bb}} {{23-26=cc}} {{31-33=dd}} {{none}} + f(bbx: 1, ccx: 2, ddx: 3, aa: 0) // expected-error {{incorrect argument labels in call (have 'bbx:ccx:ddx:aa:', expected 'aa:bb:cc:dd:')}} {{none}} } } @@ -163,6 +171,7 @@ defargs1(x: 1, z: 3) // Using defaults (out-of-order, error by SE-0060) defargs1(z: 3, y: 2, x: 1) // expected-error{{argument 'x' must precede argument 'z'}} {{10-10=x: 1, }} {{20-26=}} +// expected-error@-1 {{argument 'y' must precede argument 'z'}} {{10-10=y: 2, }} {{14-20=}} defargs1(x: 1, z: 3, y: 2) // expected-error{{argument 'y' must precede argument 'z'}} {{16-16=y: 2, }} {{20-26=}} defargs1(y: 2, x: 1) // expected-error{{argument 'x' must precede argument 'y'}} {{10-10=x: 1, }} {{14-20=}} @@ -208,7 +217,8 @@ variadics1(x: 1, y: 2, 1, 2) variadics1(x: 1, y: 2, 1, 2, 3) // Using various (out-of-order) -variadics1(1, 2, 3, 4, 5, x: 6, y: 7) // expected-error {{incorrect argument labels in call (have '_:_:_:_:_:x:y:', expected 'x:y:_:')}} {{12-12=x: }} {{15-15=y: }} {{27-30=}} {{33-36=}} +variadics1(1, 2, 3, 4, 5, x: 6, y: 7) // expected-error {{argument 'x' must precede unnamed argument #1}} {{12-12=x: 6, }} {{25-31=}} +// expected-error@-1 {{argument 'y' must precede unnamed argument #1}} {{12-12=y: 7, }} {{31-37=}} func variadics2(x: Int, y: Int = 2, z: Int...) { } // expected-note {{'variadics2(x:y:z:)' declared here}} @@ -326,15 +336,15 @@ struct Variadics7 { f(bravo: 0, alpha: 1, 2, 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} // typo A - f(alphax: 0, bravo: 3) // expected-error {{incorrect argument label in call (have 'alphax:bravo:', expected 'alpha:bravo:')}} + f(alphax: 0, bravo: 3) // expected-error {{incorrect argument label in call (have 'alphax:', expected 'alpha:')}} f(alphax: 0, 1, bravo: 3) // expected-error {{extra argument in call}} f(alphax: 0, 1, 2, bravo: 3) // expected-error {{extra arguments at positions #2, #3 in call}} // typo B f(bravox: 0) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} - f(alpha: 0, bravox: 3) // expected-error {{incorrect argument label in call (have 'alpha:bravox:', expected 'alpha:bravo:')}} - f(alpha: 0, 1, bravox: 3) // expected-error {{incorrect argument label in call (have 'alpha:_:bravox:', expected 'alpha:_:bravo:')}} - f(alpha: 0, 1, 2, bravox: 3) // expected-error {{incorrect argument label in call (have 'alpha:_:_:bravox:', expected 'alpha:_:_:bravo:')}} + f(alpha: 0, bravox: 3) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} + f(alpha: 0, 1, bravox: 3) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} + f(alpha: 0, 1, 2, bravox: 3) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} // OoO + typo A B f(bravox: 0, alphax: 1) // expected-error {{incorrect argument labels in call (have 'bravox:alphax:', expected 'alpha:bravo:')}} @@ -359,47 +369,53 @@ struct Variadics8 { f(alpha: 0, 1, charlie: 3, bravo: 4) // expected-error {{argument 'bravo' must precede argument 'charlie'}} f(alpha: 0, 1, 2, charlie: 3, bravo: 4) // expected-error {{argument 'bravo' must precede argument 'charlie'}} // OoO CAB - f(charlie: 0, alpha: 1, bravo: 4) // expected-error {{incorrect argument labels in call (have 'charlie:alpha:bravo:', expected 'alpha:bravo:charlie:')}} - f(charlie: 0, alpha: 1, 2, bravo: 4) // expected-error {{incorrect argument labels in call (have 'charlie:alpha:_:bravo:', expected 'alpha:bravo:charlie:')}} - f(charlie: 0, alpha: 1, 2, 3, bravo: 4) // expected-error {{incorrect argument labels in call (have 'charlie:alpha:_:_:bravo:', expected 'alpha:bravo:charlie:')}} + f(charlie: 0, alpha: 1, bravo: 4) // expected-error {{argument 'alpha' must precede argument 'charlie'}} + // expected-error@-1 {{argument 'bravo' must precede argument 'charlie'}} + f(charlie: 0, alpha: 1, 2, bravo: 4) // expected-error {{argument 'alpha' must precede argument 'charlie'}} + // expected-error@-1 {{argument 'bravo' must precede argument 'charlie'}} + f(charlie: 0, alpha: 1, 2, 3, bravo: 4) // expected-error {{argument 'alpha' must precede argument 'charlie'}} + // expected-error@-1 {{argument 'bravo' must precede argument 'charlie'}} + // OoO BAC f(bravo: 0, alpha: 1, charlie: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} f(bravo: 0, alpha: 1, 2, charlie: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} f(bravo: 0, alpha: 1, 2, 3, charlie: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} // typo A - f(alphax: 0, bravo: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'alphax:bravo:charlie:', expected 'alpha:bravo:charlie:')}} + f(alphax: 0, bravo: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'alphax:', expected 'alpha:')}} f(alphax: 0, 1, bravo: 3, charlie: 4) // expected-error {{extra argument in call}} f(alphax: 0, 1, 2, bravo: 3, charlie: 4) // expected-error {{extra arguments at positions #2, #3 in call}} // typo B - f(bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:charlie:', expected 'bravo:charlie:')}} - f(alpha: 0, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'alpha:bravox:charlie:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'alpha:_:bravox:charlie:', expected 'alpha:_:bravo:charlie:')}} - f(alpha: 0, 1, 2, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'alpha:_:_:bravox:charlie:', expected 'alpha:_:_:bravo:charlie:')}} + f(bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} + f(alpha: 0, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} + f(alpha: 0, 1, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} + f(alpha: 0, 1, 2, bravox: 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:', expected 'bravo:')}} // typo C - f(bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'bravo:charliex:', expected 'bravo:charlie:')}} - f(alpha: 0, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'alpha:bravo:charliex:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'alpha:_:bravo:charliex:', expected 'alpha:_:bravo:charlie:')}} - f(alpha: 0, 1, 2, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'alpha:_:_:bravo:charliex:', expected 'alpha:_:_:bravo:charlie:')}} + f(bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'charliex:', expected 'charlie:')}} + f(alpha: 0, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'charliex:', expected 'charlie:')}} + f(alpha: 0, 1, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'charliex:', expected 'charlie:')}} + f(alpha: 0, 1, 2, bravo: 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'charliex:', expected 'charlie:')}} // OoO ACB + typo B - f(alpha: 0, charlie: 3, bravox: 4) // expected-error {{incorrect argument labels in call (have 'alpha:charlie:bravox:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, charlie: 3, bravox: 4) // expected-error {{incorrect argument labels in call (have 'alpha:_:charlie:bravox:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, 2, charlie: 3, bravox: 4) // expected-error {{incorrect argument labels in call (have 'alpha:_:_:charlie:bravox:', expected 'alpha:bravo:charlie:')}} + f(alpha: 0, charlie: 3, bravox: 4) // expected-error {{incorrect argument label in call (have 'alpha:charlie:bravox:', expected 'alpha:bravo:charlie:')}} + f(alpha: 0, 1, charlie: 3, bravox: 4) // expected-error {{incorrect argument label in call (have 'alpha:charlie:bravox:', expected 'alpha:bravo:charlie:')}} + f(alpha: 0, 1, 2, charlie: 3, bravox: 4) // expected-error {{incorrect argument label in call (have 'alpha:charlie:bravox:', expected 'alpha:bravo:charlie:')}} + // OoO ACB + typo C - f(charliex: 3, bravo: 4) // expected-error {{incorrect argument labels in call (have 'charliex:bravo:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, charliex: 3, bravo: 4) // expected-error {{incorrect argument labels in call (have 'alpha:charliex:bravo:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, charliex: 3, bravo: 4) // expected-error {{incorrect argument labels in call (have 'alpha:_:charliex:bravo:', expected 'alpha:bravo:charlie:')}} - f(alpha: 0, 1, 2, charliex: 3, bravo: 4) // expected-error {{incorrect argument labels in call (have 'alpha:_:_:charliex:bravo:', expected 'alpha:bravo:charlie:')}} + f(charliex: 3, bravo: 4) // expected-error {{incorrect argument label in call (have 'charliex:bravo:', expected 'bravo:charlie:')}} + f(alpha: 0, charliex: 3, bravo: 4) // expected-error {{incorrect argument label in call (have 'alpha:charliex:bravo:', expected 'alpha:bravo:charlie:')}} + f(alpha: 0, 1, charliex: 3, bravo: 4) // expected-error {{incorrect argument label in call (have 'alpha:charliex:bravo:', expected 'alpha:bravo:charlie:')}} + f(alpha: 0, 1, 2, charliex: 3, bravo: 4) // expected-error {{incorrect argument label in call (have 'alpha:charliex:bravo:', expected 'alpha:bravo:charlie:')}} // OoO BAC + typo B - f(bravox: 0, alpha: 1, charlie: 4) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} - f(bravox: 0, alpha: 1, 2, charlie: 4) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:_:charlie:', expected 'alpha:bravo:charlie:')}} - f(bravox: 0, alpha: 1, 2, 3, charlie: 4) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:_:_:charlie:', expected 'alpha:bravo:charlie:')}} + f(bravox: 0, alpha: 1, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + f(bravox: 0, alpha: 1, 2, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + f(bravox: 0, alpha: 1, 2, 3, charlie: 4) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + // OoO BAC + typo C - f(bravo: 0, alpha: 1, charliex: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f(bravo: 0, alpha: 1, 2, charliex: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f(bravo: 0, alpha: 1, 2, 3, charliex: 4) // expected-error {{argument 'alpha' must precede argument 'bravo'}} + f(bravo: 0, alpha: 1, charliex: 4) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} + f(bravo: 0, alpha: 1, 2, charliex: 4) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} + f(bravo: 0, alpha: 1, 2, 3, charliex: 4) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} } } @@ -410,7 +426,7 @@ func testLabelErrorVariadic() { func f(aa: Int, bb: Int, cc: Int...) {} f(aax: 0, bbx: 1, cc: 2, 3, 4) - // expected-error@-1 {{incorrect argument labels in call (have 'aax:bbx:cc:_:_:', expected 'aa:bb:cc:_:_:')}} + // expected-error@-1 {{incorrect argument labels in call (have 'aax:bbx:cc:', expected 'aa:bb:cc:')}} f(aax: 0, bbx: 1) // expected-error@-1 {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} @@ -428,6 +444,8 @@ struct PositionsAroundDefaultsAndVariadics { f1(true, 2, c: "3", [4]) f1(true, c: "3", 2, [4]) // expected-error {{unnamed argument #4 must precede argument 'c'}} + // expected-error@-1 {{cannot convert value of type 'Int' to expected argument type '[Int]'}} + // expected-error@-2 {{cannot convert value of type '[Int]' to expected argument type 'Int'}} f1(true, c: "3", [4], 2) // expected-error {{unnamed argument #4 must precede argument 'c'}} @@ -436,23 +454,26 @@ struct PositionsAroundDefaultsAndVariadics { f1(true, c: "3", [4]) f1(c: "3", 2, [4]) // expected-error {{unnamed argument #3 must precede argument 'c'}} + // expected-error@-1 {{cannot convert value of type 'Int' to expected argument type '[Int]'}} + // expected-error@-2 {{cannot convert value of type '[Int]' to expected argument type 'Bool'}} f1(c: "3", [4], 2) // expected-error {{unnamed argument #3 must precede argument 'c'}} + // expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} f1(c: "3", 2) // expected-error {{cannot convert value of type 'Int' to expected argument type '[Int]'}} f1(c: "3", [4]) - f1(b: "2", [3]) // expected-error {{incorrect argument labels in call (have 'b:_:', expected '_:_:c:_:')}} + f1(b: "2", [3]) // expected-error {{incorrect argument label in call (have 'b:_:', expected '_:c:')}} // expected-error@-1 {{cannot convert value of type '[Int]' to expected argument type 'Bool'}} - - f1(b: "2", 1) // expected-error {{incorrect argument labels in call (have 'b:_:', expected '_:_:c:_:')}} + + f1(b: "2", 1) // expected-error {{incorrect argument label in call (have 'b:_:', expected '_:c:')}} // expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} - f1(b: "2", [3], 1) // expected-error {{incorrect argument labels in call (have 'b:_:_:', expected '_:_:c:_:')}} + f1(b: "2", [3], 1) // expected-error {{incorrect argument label in call (have 'b:_:_:', expected '_:_:c:')}} // expected-error@-1 {{cannot convert value of type '[Int]' to expected argument type 'Bool'}} - f1(b: "2", 1, [3]) // expected-error {{incorrect argument labels in call (have 'b:_:_:', expected '_:_:c:_:')}} + f1(b: "2", 1, [3]) // expected-error {{incorrect argument label in call (have 'b:_:_:', expected '_:_:c:')}} // expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} // expected-error@-2 {{cannot convert value of type '[Int]' to expected argument type 'Int'}} } @@ -477,7 +498,8 @@ struct PositionsAroundDefaultsAndVariadics { f2(true, c: "3", 21, [4]) // expected-error {{unnamed argument #4 must precede argument 'c'}} // expected-error@-1 {{cannot pass array of type '[Int]' as variadic arguments of type 'Int'}} - // expected-note@-2 {{remove brackets to pass array elements directly}} + // expected-error@-2 {{cannot convert value of type 'Int' to expected argument type '[Int]'}} + // expected-note@-3 {{remove brackets to pass array elements directly}} f2(true, c: "3", [4], 21) // expected-error {{unnamed argument #4 must precede argument 'c'}} @@ -502,11 +524,11 @@ struct PositionsAroundDefaultsAndVariadics { f2(c: "3", 21) // expected-error {{cannot convert value of type 'Int' to expected argument type '[Int]'}} - f2(c: "3", 21, [4]) // expected-error {{incorrect argument labels in call (have 'c:_:_:', expected '_:_:c:_:')}} + f2(c: "3", 21, [4]) // expected-error {{unnamed argument #3 must precede argument 'c'}} // expected-error@-1 {{cannot convert value of type 'Int' to expected argument type '[Int]'}} // expected-error@-2 {{cannot convert value of type '[Int]' to expected argument type 'Bool'}} - f2(c: "3", [4], 21) // expected-error {{incorrect argument labels in call (have 'c:_:_:', expected '_:_:c:_:')}} + f2(c: "3", [4], 21) // expected-error {{unnamed argument #3 must precede argument 'c'}} // expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} f2([4]) // expected-error {{cannot convert value of type '[Int]' to expected argument type 'Bool'}} @@ -609,6 +631,7 @@ struct PositionsAroundDefaultsAndVariadics { f4(31, b: "2", d: [4]) // expected-error {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} f4(b: "2", d: [4], 31) // expected-error {{unnamed argument #3 must precede argument 'b'}} + // expected-error@-1 {{type 'Int' cannot be used as a boolean; test for '!= 0' instead}} f4(b: "2", 31) f4(b: "2", 31, 32) @@ -643,7 +666,7 @@ struct PositionsAroundDefaultsAndVariadics { f5(true, c: 31, b: "2", d: [4]) // expected-error {{argument 'b' must precede argument 'c'}} - f5(true, b: "2", d: [4], 31) // expected-error {{incorrect argument labels in call (have '_:b:d:_:', expected '_:b:c:d:')}} + f5(true, b: "2", d: [4], 31) // expected-error {{incorrect argument label in call (have '_:b:d:_:', expected '_:b:c:d:')}} f5(true, b: "2", c: 31) f5(true, b: "2") @@ -702,15 +725,13 @@ func testUnlabeledParameterBindingPosition() { // expected-error@-1 {{missing argument for parameter 'aa' in call}} f(0, 1) - // expected-error@-1:6 {{missing argument label 'aa:' in call}} + // expected-error@-1:7 {{missing argument label 'aa:' in call}} f(0, xx: 1) - // expected-error@-1:7 {{missing argument for parameter 'aa' in call}} - // expected-error@-2:14 {{extra argument 'xx' in call}} + // expected-error@-1:6 {{incorrect argument labels in call (have '_:xx:', expected 'aa:_:')}} f(xx: 0, 1) - // expected-error@-1:7 {{missing argument for parameter 'aa' in call}} - // expected-error@-2:14 {{extra argument in call}} + // expected-error@-1:7 {{incorrect argument label in call (have 'xx:', expected 'aa:')}} f(0, 1, 9) // expected-error@-1:13 {{extra argument in call}} @@ -719,7 +740,7 @@ func testUnlabeledParameterBindingPosition() { // expected-error@-1:17 {{extra argument 'xx' in call}} f(xx: 91, 1, 92) - // expected-error@-1 {{extra arguments at positions #2, #3 in call}} + // expected-error@-1 {{extra arguments at positions #1, #3 in call}} // expected-error@-2 {{missing argument for parameter 'aa' in call}} } @@ -727,7 +748,7 @@ func testUnlabeledParameterBindingPosition() { func f(_ aa: Int, bb: Int, _ cc: Int) { } f(bb: 1, 0, 2) - // expected-error@-1 {{unnamed argument #3 must precede argument 'bb'}} + // expected-error@-1 {{unnamed argument #2 must precede argument 'bb'}} } do { @@ -755,7 +776,8 @@ func testUnlabeledParameterBindingPosition() { func f(aa: Int, _ bb: Int, _ cc: Int) {} f(0, 1) - // expected-error@-1:7 {{missing argument for parameter 'aa' in call}} + // expected-error@-1:7 {{missing argument label 'aa:' in call}} + // expected-error@-2:11 {{missing argument for parameter #3 in call}} } do { @@ -763,7 +785,8 @@ func testUnlabeledParameterBindingPosition() { func f(aa: Int, _ bb: Int = 81, _ cc: Int) {} f(0, 1) - // expected-error@-1:7 {{missing argument for parameter 'aa' in call}} + // expected-error@-1:7 {{missing argument label 'aa:' in call}} + // expected-error@-2:11 {{missing argument for parameter #3 in call}} } do { @@ -771,11 +794,11 @@ func testUnlabeledParameterBindingPosition() { func f(aa: Int, bb: Int, _ cc: Int) {} f(0, 2) - // expected-error@-1:6 {{missing argument labels 'aa:bb:' in call}} + // expected-error@-1:7 {{missing argument label 'aa:' in call}} // expected-error@-2:8 {{missing argument for parameter 'bb' in call}} f(0, bb: 1, 2) - // expected-error@-1:6 {{missing argument label 'aa:' in call}} + // expected-error@-1:7 {{missing argument label 'aa:' in call}} } do { @@ -818,7 +841,7 @@ extraargs1(x: 1, 2, 3) // expected-error{{extra arguments at positions #2, #3 in func mismatch1(thisFoo: Int = 0, bar: Int = 0, wibble: Int = 0) { } // expected-note {{'mismatch1(thisFoo:bar:wibble:)' declared here}} mismatch1(foo: 5) // expected-error {{extra argument 'foo' in call}} -mismatch1(baz: 1, wobble: 2) // expected-error{{incorrect argument labels in call (have 'baz:wobble:', expected 'bar:wibble:')}} {{11-14=bar}} {{19-25=wibble}} +mismatch1(baz: 1, wobble: 2) // expected-error{{incorrect argument labels in call (have 'baz:wobble:', expected 'bar:wibble:')}} {{none}} mismatch1(food: 1, zap: 2) // expected-error{{extra arguments at positions #1, #2 in call}} // QoI: FailureDiagnosis doesn't look through 'try' @@ -829,7 +852,7 @@ struct rdar27891805 { } try rdar27891805(contentsOfURL: nil, usedEncoding: nil) -// expected-error@-1 {{incorrect argument label in call (have 'contentsOfURL:usedEncoding:', expected 'contentsOf:usedEncoding:')}} +// expected-error@-1 {{incorrect argument label in call (have 'contentsOfURL:', expected 'contentsOf:')}} // expected-error@-2 {{'nil' is not compatible with expected argument type 'String'}} // expected-error@-3 {{'nil' is not compatible with expected argument type 'String'}} @@ -845,14 +868,14 @@ struct OutOfOrderAndDefault { func test1() { // typo - f11(bravo: 0, alphax: 1) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} - f11(bravox: 0, alpha: 1) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} - f12(bravo: 0, alphax: 1) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} - f12(bravox: 0, alpha: 1) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} - f13(bravo: 0, alphax: 1) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} - f13(bravox: 0, alpha: 1) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} - f14(bravo: 0, alphax: 1) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} - f14(bravox: 0, alpha: 1) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} + f11(bravo: 0, alphax: 1) // expected-error {{incorrect argument label in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} + f11(bravox: 0, alpha: 1) // expected-error {{incorrect argument label in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} + f12(bravo: 0, alphax: 1) // expected-error {{incorrect argument label in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} + f12(bravox: 0, alpha: 1) // expected-error {{incorrect argument label in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} + f13(bravo: 0, alphax: 1) // expected-error {{incorrect argument label in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} + f13(bravox: 0, alpha: 1) // expected-error {{incorrect argument label in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} + f14(bravo: 0, alphax: 1) // expected-error {{incorrect argument label in call (have 'bravo:alphax:', expected 'alpha:bravo:')}} + f14(bravox: 0, alpha: 1) // expected-error {{incorrect argument label in call (have 'bravox:alpha:', expected 'alpha:bravo:')}} } func f21(alpha: Int, bravo: Int, charlie: Int) {} @@ -861,37 +884,37 @@ struct OutOfOrderAndDefault { func test2() { // BAC - f21(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} - f21(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} - f21(bravo: 0, alpha: 1, charliex: 2) // expected-error {{'alpha' must precede argument 'bravo'}} - f22(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} - f22(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} - f22(bravo: 0, alpha: 1, charliex: 2) // expected-error {{'alpha' must precede argument 'bravo'}} - f23(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} - f23(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} - f23(bravo: 0, alpha: 1, charliex: 2) // expected-error {{'alpha' must precede argument 'bravo'}} + f21(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} + f21(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + f21(bravo: 0, alpha: 1, charliex: 2) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} + f22(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} + f22(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + f22(bravo: 0, alpha: 1, charliex: 2) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} + f23(bravo: 0, alphax: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:', expected 'alpha:bravo:charlie:')}} + f23(bravox: 0, alpha: 1, charlie: 2) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:', expected 'alpha:bravo:charlie:')}} + f23(bravo: 0, alpha: 1, charliex: 2) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:', expected 'alpha:bravo:charlie:')}} // BCA - f21(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} - f21(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} - f21(bravo: 0, charliex: 1, alpha: 2) // expected-error {{'alpha' must precede argument 'bravo'}} - f22(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} - f22(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} - f22(bravo: 0, charliex: 1, alpha: 2) // expected-error {{'alpha' must precede argument 'bravo'}} - f23(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} - f23(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} - f23(bravo: 0, charliex: 1, alpha: 2) // expected-error {{'alpha' must precede argument 'bravo'}} + f21(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} + f21(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} + f21(bravo: 0, charliex: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:', expected 'alpha:bravo:charlie:')}} + f22(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} + f22(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} + f22(bravo: 0, charliex: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:', expected 'alpha:bravo:charlie:')}} + f23(bravo: 0, charlie: 1, alphax: 2) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:', expected 'alpha:bravo:charlie:')}} + f23(bravox: 0, charlie: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:', expected 'alpha:bravo:charlie:')}} + f23(bravo: 0, charliex: 1, alpha: 2) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:', expected 'alpha:bravo:charlie:')}} // CAB - f21(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} - f21(charlie: 0, alpha: 1, bravox: 2) // expected-error {{incorrect argument labels in call (have 'charlie:alpha:bravox:', expected 'alpha:bravo:charlie:')}} - f21(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} - f22(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} - f22(charlie: 0, alpha: 1, bravox: 2) // expected-error {{incorrect argument labels in call (have 'charlie:alpha:bravox:', expected 'alpha:bravo:charlie:')}} - f22(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} - f23(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} - f23(charlie: 0, alpha: 1, bravox: 2) // expected-error {{argument 'alpha' must precede argument 'charlie'}} - f23(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument labels in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} + f21(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} + f21(charlie: 0, alpha: 1, bravox: 2) // expected-error {{incorrect argument label in call (have 'charlie:alpha:bravox:', expected 'alpha:bravo:charlie:')}} + f21(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} + f22(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} + f22(charlie: 0, alpha: 1, bravox: 2) // expected-error {{incorrect argument label in call (have 'charlie:alpha:bravox:', expected 'alpha:bravo:charlie:')}} + f22(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} + f23(charlie: 0, alphax: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charlie:alphax:bravo:', expected 'alpha:bravo:charlie:')}} + f23(charlie: 0, alpha: 1, bravox: 2) // expected-error {{incorrect argument label in call (have 'charlie:alpha:bravox:', expected 'alpha:bravo:charlie:')}} + f23(charliex: 0, alpha: 1, bravo: 2) // expected-error {{incorrect argument label in call (have 'charliex:alpha:bravo:', expected 'alpha:bravo:charlie:')}} } func f31(alpha: Int, bravo: Int, charlie: Int, delta: Int) {} @@ -900,32 +923,32 @@ struct OutOfOrderAndDefault { func test3() { // BACD - f31(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f31(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f31(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f31(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f32(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f32(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f32(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f32(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f33(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f33(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} - f33(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f33(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} + f31(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charlie:deltax:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charlie:deltax:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, alphax: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alphax:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravox: 0, alpha: 2, charlie: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:alpha:charlie:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, alpha: 2, charliex: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charliex:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, alpha: 2, charlie: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:alpha:charlie:deltax:', expected 'alpha:bravo:charlie:delta:')}} // BCAD - f31(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} - f31(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} - f31(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f31(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f32(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} - f32(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} - f32(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f32(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f33(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} - f33(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument labels in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} - f33(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} - f33(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{argument 'alpha' must precede argument 'bravo'}} + f31(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f31(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alpha:deltax:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f32(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alpha:deltax:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, charlie: 1, alphax: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alphax:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravox: 0, charlie: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravox:charlie:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, charliex: 1, alpha: 2, delta: 3) // expected-error {{incorrect argument label in call (have 'bravo:charliex:alpha:delta:', expected 'alpha:bravo:charlie:delta:')}} + f33(bravo: 0, charlie: 1, alpha: 2, deltax: 3) // expected-error {{incorrect argument label in call (have 'bravo:charlie:alpha:deltax:', expected 'alpha:bravo:charlie:delta:')}} } } @@ -1038,11 +1061,11 @@ struct RelabelAndTrailingClosure { func f2(aa: Int, bb: Int, _ cc: () -> Void = {}) {} func test() { - f1(aax: 1, bbx: 2) {} // expected-error {{incorrect argument labels in call (have 'aax:bbx:_:', expected 'aa:bb:cc:')}} {{8-11=aa}} {{16-19=bb}} {{none}} - f2(aax: 1, bbx: 2) {} // expected-error {{incorrect argument labels in call (have 'aax:bbx:_:', expected 'aa:bb:_:')}} {{8-11=aa}} {{16-19=bb}} {{none}} + f1(aax: 1, bbx: 2) {} // expected-error {{incorrect argument labels in call (have 'aax:bbx:cc:', expected 'aa:bb:cc:')}} {{none}} + f2(aax: 1, bbx: 2) {} // expected-error {{incorrect argument labels in call (have 'aax:bbx:_:', expected 'aa:bb:_:')}} {{none}} - f1(aax: 1, bbx: 2) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{8-11=aa}} {{16-19=bb}} {{none}} - f2(aax: 1, bbx: 2) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{8-11=aa}} {{16-19=bb}} {{none}} + f1(aax: 1, bbx: 2) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} + f2(aax: 1, bbx: 2) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} } } @@ -1159,7 +1182,7 @@ _ = CurriedClass.method3(1, 2) // expected-error {{instance member 'me // expected-error@-1 {{missing argument label 'b:' in call}} CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}} -CurriedClass.method3(c)(c: 1.0) // expected-error {{incorrect argument labels in call (have 'c:', expected '_:b:')}} +CurriedClass.method3(c)(c: 1.0) // expected-error {{incorrect argument label in call (have 'c:', expected 'b:')}} // expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} // expected-error@-2 {{missing argument for parameter #1 in call}} @@ -1197,7 +1220,7 @@ func testLabelErrorsBasic() { // 1 wrong f(0, 1, ccx: 2, dd: 3, ee: 4, ff: 5) - // expected-error@-1 {{incorrect argument label in call (have '_:_:ccx:dd:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{11-14=cc}} {{none}} + // expected-error@-1 {{incorrect argument label in call (have 'ccx:', expected 'cc:')}} {{11-14=cc}} {{none}} // 1 missing f(0, 1, 2, dd: 3, ee: 4, ff: 5) @@ -1213,7 +1236,7 @@ func testLabelErrorsBasic() { // 2 wrong f(0, 1, ccx: 2, ddx: 3, ee: 4, ff: 5) - // expected-error@-1 {{incorrect argument labels in call (have '_:_:ccx:ddx:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{11-14=cc}} {{19-22=dd}} {{none}} + // expected-error@-1 {{incorrect argument labels in call (have '_:_:ccx:ddx:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{none}} // 2 missing f(0, 1, 2, 3, ee: 4, ff: 5) @@ -1226,26 +1249,27 @@ func testLabelErrorsBasic() { // 2 ooo f(0, 1, dd: 3, cc: 2, ff: 5, ee: 4) // expected-error@-1 {{argument 'cc' must precede argument 'dd'}} {{16-23=}} {{11-11=cc: 2, }} {{none}} + // expected-error@-2 {{argument 'ee' must precede argument 'ff'}} {{30-37=}} {{25-25=ee: 4, }} {{none}} // 1 wrong + 1 missing f(0, 1, ccx: 2, 3, ee: 4, ff: 5) - // expected-error@-1 {{incorrect argument labels in call (have '_:_:ccx:_:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{11-14=cc}} {{19-19=dd: }} {{none}} + // expected-error@-1 {{incorrect argument labels in call (have '_:_:ccx:_:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{none}} // 1 wrong + 1 extra f(aa: 0, 1, ccx: 2, dd: 3, ee: 4, ff: 5) - // expected-error@-1 {{incorrect argument labels in call (have 'aa:_:ccx:dd:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{5-9=}} {{15-18=cc}} {{none}} + // expected-error@-1 {{incorrect argument labels in call (have 'aa:_:ccx:dd:ee:ff:', expected '_:_:cc:dd:ee:ff:')}} {{none}} // 1 wrong + 1 ooo f(0, 1, ccx: 2, dd: 3, ff: 5, ee: 4) - // expected-error@-1 {{incorrect argument labels in call (have '_:_:ccx:dd:ff:ee:', expected '_:_:cc:dd:ee:ff:')}} {{11-14=cc}} {{26-28=ee}} {{33-35=ff}} {{none}} + // expected-error@-1 {{incorrect argument label in call (have '_:_:ccx:dd:ff:ee:', expected '_:_:cc:dd:ee:ff:')}} {{none}} } struct DiagnoseAllLabels { func f(aa: Int, bb: Int, cc: Int..., dd: Int, ee: Int = 0, ff: Int = 0) {} func test() { - f(aax: 0, bbx: 1, cc: 21, 22, 23, dd: 3, ff: 5) // expected-error {{incorrect argument labels in call (have 'aax:bbx:cc:_:_:dd:ff:', expected 'aa:bb:cc:_:_:dd:ff:')}} {{7-10=aa}} {{15-18=bb}} {{none}} + f(aax: 0, bbx: 1, cc: 21, 22, 23, dd: 3, ff: 5) // expected-error {{incorrect argument labels in call (have 'aax:bbx:cc:dd:ff:', expected 'aa:bb:cc:dd:ff:')}} {{none}} - f(aax: 0, bbx: 1, dd: 3, ff: 5) // expected-error {{incorrect argument labels in call (have 'aax:bbx:dd:ff:', expected 'aa:bb:dd:ff:')}} {{7-10=aa}} {{15-18=bb}} {{none}} + f(aax: 0, bbx: 1, dd: 3, ff: 5) // expected-error {{incorrect argument labels in call (have 'aax:bbx:dd:ff:', expected 'aa:bb:dd:ff:')}} {{none}} } } diff --git a/test/Constraints/diagnostics.swift b/test/Constraints/diagnostics.swift index 003387b8829e6..ad1751676d090 100644 --- a/test/Constraints/diagnostics.swift +++ b/test/Constraints/diagnostics.swift @@ -398,9 +398,9 @@ enum Color { static func rainbow() -> Color {} - static func overload(a : Int) -> Color {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(a:)')}} + static func overload(a : Int) -> Color {} // expected-note {{missing label for candidate parameter 'a:'}} // expected-note@-1 {{candidate has partially matching parameter list (a: Int)}} - static func overload(b : Int) -> Color {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(b:)')}} + static func overload(b : Int) -> Color {} // expected-note {{missing label for candidate parameter 'b:'}} // expected-note@-1 {{candidate has partially matching parameter list (b: Int)}} static func frob(_ a : Int, b : inout Int) -> Color {} diff --git a/test/Constraints/optional.swift b/test/Constraints/optional.swift index d3bf1c65a1121..ea464280e42a9 100644 --- a/test/Constraints/optional.swift +++ b/test/Constraints/optional.swift @@ -10,8 +10,8 @@ class A { @objc(do_b_2:) func do_b(_ x: Int) {} @objc func do_b(_ x: Float) {} - @objc func do_c(x: Int) {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(x:)')}} - @objc func do_c(y: Int) {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(y:)')}} + @objc func do_c(x: Int) {} // expected-note {{missing label for candidate parameter 'x:'}} + @objc func do_c(y: Int) {} // expected-note {{missing label for candidate parameter 'y:'}} } func test0(_ a: AnyObject) { diff --git a/test/Constraints/unchecked_optional.swift b/test/Constraints/unchecked_optional.swift index 36e7460a08aa3..019d7d3740d15 100644 --- a/test/Constraints/unchecked_optional.swift +++ b/test/Constraints/unchecked_optional.swift @@ -6,8 +6,8 @@ class A { func do_b(_ x: Int) {} func do_b(_ x: Float) {} - func do_c(x: Int) {} // expected-note 2 {{incorrect labels for candidate (have: '(_:)', expected: '(x:)')}} - func do_c(y: Int) {} // expected-note 2 {{incorrect labels for candidate (have: '(_:)', expected: '(y:)')}} + func do_c(x: Int) {} // expected-note 2 {{missing label for candidate parameter 'x:'}} + func do_c(y: Int) {} // expected-note 2 {{missing label for candidate parameter 'y:'}} } func test0(_ a : A!) { diff --git a/test/FixCode/verify-fixits.swift b/test/FixCode/verify-fixits.swift index 01abb375f8133..1efe07f6c16ae 100644 --- a/test/FixCode/verify-fixits.swift +++ b/test/FixCode/verify-fixits.swift @@ -25,43 +25,43 @@ func test0Fixits() { } func test1Fixits() { - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{15-15=xx: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{15-15=xx: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{15-15=aa: }} {{none}} } func test2Fixits() { - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=xx}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=xx: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=xx: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=xx: }} {{none}} } diff --git a/test/FixCode/verify-fixits.swift.result b/test/FixCode/verify-fixits.swift.result index c67ded51a9ddc..535830cba297f 100644 --- a/test/FixCode/verify-fixits.swift.result +++ b/test/FixCode/verify-fixits.swift.result @@ -25,43 +25,43 @@ func test0Fixits() { } func test1Fixits() { - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} } func test2Fixits() { - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} } diff --git a/test/Frontend/verify-fixits.swift b/test/Frontend/verify-fixits.swift index 025b7a22d623b..a37ef6310951d 100644 --- a/test/Frontend/verify-fixits.swift +++ b/test/Frontend/verify-fixits.swift @@ -31,55 +31,55 @@ func test0Fixits() { } func test1Fixits() { - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} + // CHECK: [[@LINE+1]]:84: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} + // CHECK: [[@LINE+1]]:99: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{15-15=xx: }} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} + // CHECK: [[@LINE+1]]:84: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{15-15=aa: }} - // CHECK: [[@LINE+1]]:121: error: expected no fix-its; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{none}} + // CHECK: [[@LINE+1]]:84: error: expected no fix-its; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{none}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{none}} + // CHECK: [[@LINE+1]]:84: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{none}} - // CHECK: [[@LINE+1]]:134: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=aa}} {{15-18=xx}} {{none}} + // CHECK: [[@LINE+1]]:99: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=aa: }} {{15-15=xx: }} {{none}} - // CHECK: [[@LINE+1]]:121: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-18=aa}} - labeledFunc(aax: 0, bb: 1) // expected-error {{incorrect argument label in call (have 'aax:bb:', expected 'aa:bb:')}} {{15-18=xx}} {{15-18=aa}} {{none}} + // CHECK: [[@LINE+1]]:84: error: expected fix-it not seen; actual fix-it seen: {{{{}}15-15=aa: }} + labeledFunc(0, bb: 1) // expected-error {{missing argument label 'aa:' in call}} {{15-15=xx: }} {{15-15=aa: }} {{none}} } func test2Fixits() { - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} - // CHECK: [[@LINE+1]]:124: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=xx}} + // CHECK: [[@LINE+1]]:84: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-15=aa: }} {{{{}}18-18=bb: }} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=xx: }} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} + // CHECK: [[@LINE+1]]:99: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-15=aa: }} {{{{}}18-18=bb: }} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=xx: }} - // CHECK: [[@LINE+1]]:124: error: expected no fix-its; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{none}} + // CHECK: [[@LINE+1]]:84: error: expected no fix-its; actual fix-its seen: {{{{}}15-15=aa: }} {{{{}}18-18=bb: }} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{none}} - // CHECK: [[@LINE+1]]:137: error: unexpected fix-it seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{none}} + // CHECK: [[@LINE+1]]:99: error: unexpected fix-it seen; actual fix-its seen: {{{{}}15-15=aa: }} {{{{}}18-18=bb: }} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{none}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=bb}} {{none}} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=bb: }} {{none}} - // CHECK: [[@LINE+1]]:137: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-18=aa}} {{{{}}23-26=bb}} - labeledFunc(aax: 0, bbx: 1) // expected-error {{incorrect argument labels in call (have 'aax:bbx:', expected 'aa:bb:')}} {{15-18=aa}} {{23-26=xx}} {{none}} + // CHECK: [[@LINE+1]]:99: error: expected fix-it not seen; actual fix-its seen: {{{{}}15-15=aa: }} {{{{}}18-18=bb: }} + labeledFunc(0, 1) // expected-error {{missing argument labels 'aa:bb:' in call}} {{15-15=aa: }} {{18-18=xx: }} {{none}} } diff --git a/test/expr/unary/keypath/keypath.swift b/test/expr/unary/keypath/keypath.swift index 449876f2c8b98..e1e7acfd8baf9 100644 --- a/test/expr/unary/keypath/keypath.swift +++ b/test/expr/unary/keypath/keypath.swift @@ -854,8 +854,8 @@ func sr11562() { _ = \S1.[5] // expected-error {{missing argument label 'x:' in call}} {{12-12=x: }} struct S2 { - subscript(x x: Int) -> Int { x } // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(x:)')}} - subscript(y y: Int) -> Int { y } // expected-note {{incorrect labels for candidate (have: '(_:)', expected: '(y:)')}} + subscript(x x: Int) -> Int { x } // expected-note {{missing label for candidate parameter 'x:'}} + subscript(y y: Int) -> Int { y } // expected-note {{missing label for candidate parameter 'y:'}} } _ = \S2.[5] // expected-error {{no exact matches in call to subscript}} diff --git a/validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift b/validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift index 8a943ea956e10..bdda4a10642f3 100644 --- a/validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift +++ b/validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift @@ -4,7 +4,7 @@ extension BinaryInteger { init(bytes: [UInt8]) { fatalError() } init(bytes: S) where S.Iterator.Element == UInt8 { - // expected-note@-1 {{incorrect labels for candidate (have: '(_:)', expected: '(bytes:)')}} + // expected-note@-1 {{missing label for candidate parameter 'bytes:'}} self.init(bytes // expected-error {{no exact matches in call to initializer}} // expected-note@-1 {{}}