diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index a8f858e8034f9..92469f8d678df 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -7101,6 +7101,14 @@ class ParamDecl : public VarDecl { Identifier parameterName, Expr *defaultValue, DefaultArgumentInitializer *defaultValueInitContext, DeclContext *dc); + SourceLoc getLocFromSource() const { + // If we have a name loc, use it, otherwise fallback to the start loc for + // e.g enum elements without parameter names. + if (auto nameLoc = getNameLoc()) + return nameLoc; + return getStartLoc(); + } + /// Retrieve the argument (API) name for this function parameter. Identifier getArgumentName() const { return ArgumentNameAndFlags.getPointer(); diff --git a/include/swift/AST/TypeMatcher.h b/include/swift/AST/TypeMatcher.h index ab6d90eb2190d..fcaf361a91856 100644 --- a/include/swift/AST/TypeMatcher.h +++ b/include/swift/AST/TypeMatcher.h @@ -117,6 +117,12 @@ class TypeMatcher { #define SINGLETON_TYPE(SHORT_ID, ID) TRIVIAL_CASE(ID##Type) #include "swift/AST/TypeNodes.def" + bool visitPlaceholderType(CanPlaceholderType firstType, Type secondType, + Type sugaredFirstType) { + // Placeholder types never match. + return mismatch(firstType.getPointer(), secondType, sugaredFirstType); + } + bool visitUnresolvedType(CanUnresolvedType firstType, Type secondType, Type sugaredFirstType) { // Unresolved types never match. diff --git a/include/swift/Sema/CSFix.h b/include/swift/Sema/CSFix.h index c6e5be5319005..bb618b0e1b09e 100644 --- a/include/swift/Sema/CSFix.h +++ b/include/swift/Sema/CSFix.h @@ -362,6 +362,9 @@ enum class FixKind : uint8_t { /// resolved. SpecifyTypeForPlaceholder, + /// Ignore an invalid placeholder in a decl's interface type. + IgnoreInvalidPlaceholderInDeclRef, + /// Allow Swift -> C pointer conversion in an argument position /// of a Swift function. AllowSwiftToCPointerConversion, @@ -3191,6 +3194,30 @@ class SpecifyTypeForPlaceholder final : public ConstraintFix { } }; +class IgnoreInvalidPlaceholderInDeclRef final : public ConstraintFix { + IgnoreInvalidPlaceholderInDeclRef(ConstraintSystem &cs, + ConstraintLocator *locator) + : ConstraintFix(cs, FixKind::IgnoreInvalidPlaceholderInDeclRef, locator) {} + +public: + std::string getName() const override { + return "ignore invalid placeholder in decl ref"; + } + + bool diagnose(const Solution &solution, bool asNote = false) const override; + + bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override { + return diagnose(*commonFixes.front().first); + } + + static IgnoreInvalidPlaceholderInDeclRef *create(ConstraintSystem &cs, + ConstraintLocator *locator); + + static bool classof(const ConstraintFix *fix) { + return fix->getKind() == FixKind::IgnoreInvalidPlaceholderInDeclRef; + } +}; + class AllowRefToInvalidDecl final : public ConstraintFix { AllowRefToInvalidDecl(ConstraintSystem &cs, ConstraintLocator *locator) : ConstraintFix(cs, FixKind::AllowRefToInvalidDecl, locator) {} diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c7b0d15309108..ac76b08bc59b1 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4686,6 +4686,8 @@ isAnyFunctionTypeCanonical(ArrayRef params, // For now, generic function types cannot be dependent (in fact, // they erase dependence) or contain type variables, and they're // always materializable. +// FIXME: This doesn't seem great, we should consider changing it to be opt-out +// rather than opt-in. static RecursiveTypeProperties getGenericFunctionRecursiveProperties(ArrayRef params, Type result, Type globalActor, @@ -4694,34 +4696,25 @@ getGenericFunctionRecursiveProperties(ArrayRef params, "revisit this if you add new recursive type properties"); RecursiveTypeProperties properties; - for (auto param : params) { - if (param.getPlainType()->getRecursiveProperties().hasError()) - properties |= RecursiveTypeProperties::HasError; - if (param.getPlainType()->getRecursiveProperties().isUnsafe()) - properties |= RecursiveTypeProperties::IsUnsafe; - } + using Prop = RecursiveTypeProperties::Property; + auto mask = (unsigned)Prop::HasError | Prop::IsUnsafe | Prop::HasPlaceholder; + + auto unionBits = [&](Type ty) { + if (!ty) + return; + auto bits = ty->getRecursiveProperties().getBits(); + properties |= Prop(bits & mask); + }; + + for (auto param : params) + unionBits(param.getPlainType()); if (result->getRecursiveProperties().hasDynamicSelf()) properties |= RecursiveTypeProperties::HasDynamicSelf; - if (result->getRecursiveProperties().hasError()) - properties |= RecursiveTypeProperties::HasError; - if (result->getRecursiveProperties().isUnsafe()) - properties |= RecursiveTypeProperties::IsUnsafe; - - if (globalActor) { - if (globalActor->getRecursiveProperties().hasError()) - properties |= RecursiveTypeProperties::HasError; - if (globalActor->getRecursiveProperties().isUnsafe()) - properties |= RecursiveTypeProperties::IsUnsafe; - } - - if (thrownError) { - if (thrownError->getRecursiveProperties().hasError()) - properties |= RecursiveTypeProperties::HasError; - if (thrownError->getRecursiveProperties().isUnsafe()) - properties |= RecursiveTypeProperties::IsUnsafe; - } + unionBits(result); + unionBits(globalActor); + unionBits(thrownError); return properties; } diff --git a/lib/Sema/AssociatedTypeInference.cpp b/lib/Sema/AssociatedTypeInference.cpp index 665b8af1178b4..81c9ddad13b65 100644 --- a/lib/Sema/AssociatedTypeInference.cpp +++ b/lib/Sema/AssociatedTypeInference.cpp @@ -2317,9 +2317,9 @@ AssociatedTypeInference::getPotentialTypeWitnessesByMatchingTypes(ValueDecl *req /// Deduce associated types from dependent member types in the witness. bool mismatch(DependentMemberType *firstDepMember, TypeBase *secondType, Type sugaredFirstType) { - // If the second type is an error, don't look at it further, but proceed - // to find other matches. - if (secondType->hasError()) + // If the second type is an error or placeholder, don't look at it + // further, but proceed to find other matches. + if (secondType->hasError() || secondType->hasPlaceholder()) return true; // If the second type is a generic parameter of the witness, the match diff --git a/lib/Sema/CSFix.cpp b/lib/Sema/CSFix.cpp index d0a27a56131f4..f2b18034b7eac 100644 --- a/lib/Sema/CSFix.cpp +++ b/lib/Sema/CSFix.cpp @@ -2264,6 +2264,20 @@ SpecifyTypeForPlaceholder::create(ConstraintSystem &cs, return new (cs.getAllocator()) SpecifyTypeForPlaceholder(cs, locator); } +IgnoreInvalidPlaceholderInDeclRef * +IgnoreInvalidPlaceholderInDeclRef::create(ConstraintSystem &cs, ConstraintLocator *locator) { + return new (cs.getAllocator()) IgnoreInvalidPlaceholderInDeclRef(cs, locator); +} + +bool +IgnoreInvalidPlaceholderInDeclRef::diagnose(const Solution &solution, + bool asNote) const { + // These are diagnosed separately. Unfortunately we can't enforce that a + // diagnostic has already been emitted since their diagnosis depends on e.g + // type-checking a function body for a placeholder result of a function. + return true; +} + bool AllowRefToInvalidDecl::diagnose(const Solution &solution, bool asNote) const { ReferenceToInvalidDeclaration failure(solution, getLocator()); diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp index 0d1b17a189db8..91adbaf8cf496 100644 --- a/lib/Sema/CSGen.cpp +++ b/lib/Sema/CSGen.cpp @@ -2542,8 +2542,11 @@ namespace { Type thrownErrorTy = [&] { // Explicitly-specified thrown type. if (closure->getExplicitThrownTypeRepr()) { - if (Type explicitType = closure->getExplicitThrownType()) - return explicitType; + if (Type explicitType = closure->getExplicitThrownType()) { + // The thrown type may have errors, open as placeholders if needed. + return CS.replaceInferableTypesWithTypeVars(explicitType, + thrownErrorLocator); + } } // Explicitly-specified 'throws' without a type is untyped throws. diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp index ad8c12c221404..8d30ce5dbade3 100644 --- a/lib/Sema/CSSimplify.cpp +++ b/lib/Sema/CSSimplify.cpp @@ -16109,6 +16109,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint( case FixKind::AllowValueExpansionWithoutPackReferences: case FixKind::IgnoreInvalidPatternInExpr: case FixKind::IgnoreInvalidPlaceholder: + case FixKind::IgnoreInvalidPlaceholderInDeclRef: case FixKind::IgnoreOutOfPlaceThenStmt: case FixKind::IgnoreMissingEachKeyword: case FixKind::AllowInlineArrayLiteralCountMismatch: diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index c91e0e3f7af28..ddfff7388497d 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -2121,10 +2121,17 @@ ResultTypeRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const { if (decl->preconcurrency()) options |= TypeResolutionFlags::Preconcurrency; + // Placeholders are only currently allowed for FuncDecls with bodies, which + // we diagnose in ReturnTypePlaceholderReplacer. + HandlePlaceholderTypeReprFn placeholderOpener; + if (auto *FD = dyn_cast(decl)) { + if (FD->hasBody() && !FD->isBodySkipped()) + placeholderOpener = PlaceholderType::get; + } auto *const dc = decl->getInnermostDeclContext(); return TypeResolution::forInterface(dc, options, /*unboundTyOpener*/ nullptr, - PlaceholderType::get, + placeholderOpener, /*packElementOpener*/ nullptr) .resolveType(resultTyRepr); } @@ -2310,9 +2317,17 @@ static Type validateParameterType(ParamDecl *decl) { : TypeResolverContext::FunctionInput); options |= TypeResolutionFlags::Direct; + // We allow placeholders in parameter types to improve recovery since if a + // default argument is present we can suggest the inferred type. Avoid doing + // this for protocol requirements though since those can't ever have default + // arguments anyway. + HandlePlaceholderTypeReprFn placeholderOpener; + if (!isa(dc->getParent())) + placeholderOpener = PlaceholderType::get; + const auto resolution = TypeResolution::forInterface(dc, options, unboundTyOpener, - PlaceholderType::get, + placeholderOpener, /*packElementOpener*/ nullptr); if (isa(nestedRepr)) { @@ -3026,9 +3041,11 @@ bool TypeChecker::isPassThroughTypealias(TypeAliasDecl *typealias, Type ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const { - auto error = [&ext]() { + auto &ctx = ext->getASTContext(); + + auto error = [&]() { ext->setInvalid(); - return ErrorType::get(ext->getASTContext()); + return ErrorType::get(ctx); }; // If we didn't parse a type, fill in an error type and bail out. @@ -3052,6 +3069,15 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const { if (extendedType->hasError()) return error(); + auto &diags = ctx.Diags; + + // Cannot extend types who contain placeholders. + if (extendedType->hasPlaceholder()) { + diags.diagnose(ext->getLoc(), diag::extension_placeholder) + .highlight(extendedRepr->getSourceRange()); + return error(); + } + // Hack to allow extending a generic typealias. if (auto *unboundGeneric = extendedType->getAs()) { if (auto *aliasDecl = dyn_cast(unboundGeneric->getDecl())) { @@ -3069,8 +3095,6 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const { } } - auto &diags = ext->getASTContext().Diags; - // Cannot extend a metatype. if (extendedType->is()) { diags.diagnose(ext->getLoc(), diag::extension_metatype, extendedType) @@ -3087,13 +3111,6 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const { return error(); } - // Cannot extend types who contain placeholders. - if (extendedType->hasPlaceholder()) { - diags.diagnose(ext->getLoc(), diag::extension_placeholder) - .highlight(extendedRepr->getSourceRange()); - return error(); - } - return extendedType; } diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp index 30698e39228db..a9c7815541f7e 100644 --- a/lib/Sema/TypeCheckType.cpp +++ b/lib/Sema/TypeCheckType.cpp @@ -6999,7 +6999,7 @@ Type ExplicitCaughtTypeRequest::evaluate( return TypeResolution::forInterface(func, options, /*unboundTyOpener*/ nullptr, - PlaceholderType::get, + /*placeholderOpener*/ nullptr, /*packElementOpener*/ nullptr) .resolveType(thrownTypeRepr); } @@ -7011,7 +7011,7 @@ Type ExplicitCaughtTypeRequest::evaluate( return TypeResolution::resolveContextualType( thrownTypeRepr, closure, TypeResolutionOptions(TypeResolverContext::None), - /*unboundTyOpener*/ nullptr, PlaceholderType::get, + /*unboundTyOpener*/ nullptr, /*placeholderOpener*/ nullptr, /*packElementOpener*/ nullptr); } @@ -7045,7 +7045,7 @@ Type ExplicitCaughtTypeRequest::evaluate( return TypeResolution::resolveContextualType( typeRepr, doCatch->getDeclContext(), TypeResolutionOptions(TypeResolverContext::None), - /*unboundTyOpener*/ nullptr, PlaceholderType::get, + /*unboundTyOpener*/ nullptr, /*placeholderOpener*/ nullptr, /*packElementOpener*/ nullptr); } diff --git a/lib/Sema/TypeOfReference.cpp b/lib/Sema/TypeOfReference.cpp index e504b4b4444db..78236a8c0ae3d 100644 --- a/lib/Sema/TypeOfReference.cpp +++ b/lib/Sema/TypeOfReference.cpp @@ -1080,6 +1080,31 @@ static Type replaceParamErrorTypeByPlaceholder(Type type, ValueDecl *value, bool funcType->getExtInfo()); } +/// We allow placeholder types in interface types in certain cases to allow +/// better recovery since we can suggest the inferred type as a replacement. +/// When referencing those decls though we need to make sure we record a fix +/// since we cannot form a valid solution with them. +static void +recordFixIfNeededForPlaceholderInDecl(ConstraintSystem &cs, ValueDecl *D, + ConstraintLocatorBuilder locator) { + auto mayHavePlaceholder = [&]() -> bool { + // Parameters with types may have placeholders, since this allows us to + // suggest an inferred type from a default argument. Match the logic in + // `getUnopenedTypeOfReference` and only query the interface type if we have + // one already. + if (auto *PD = dyn_cast(D)) + return PD->hasInterfaceType(); + + // Therefore decls with parameter lists may also have placeholders. + return D->getParameterList(); + }; + if (!mayHavePlaceholder() || !D->getInterfaceType()->hasPlaceholder()) + return; + + auto *loc = cs.getConstraintLocator(locator); + cs.recordFix(IgnoreInvalidPlaceholderInDeclRef::create(cs, loc)); +} + DeclReferenceType ConstraintSystem::getTypeOfReference(ValueDecl *value, FunctionRefInfo functionRefInfo, @@ -1087,6 +1112,7 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value, DeclContext *useDC, PreparedOverloadBuilder *preparedOverload) { ASSERT(!!preparedOverload == PreparingOverload); + recordFixIfNeededForPlaceholderInDecl(*this, value, locator); if (value->getDeclContext()->isTypeContext() && isa(value)) { // Unqualified lookup can find operator names within nominal types. @@ -1777,6 +1803,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference( SmallVectorImpl *replacementsPtr, PreparedOverloadBuilder *preparedOverload) { ASSERT(!!preparedOverload == PreparingOverload); + recordFixIfNeededForPlaceholderInDecl(*this, value, locator); // Figure out the instance type used for the base. Type baseRValueTy = baseTy->getRValueType(); diff --git a/test/Sema/placeholder_type.swift b/test/Sema/placeholder_type.swift index 2ac79e3d7e70c..2b619ec8f0cb0 100644 --- a/test/Sema/placeholder_type.swift +++ b/test/Sema/placeholder_type.swift @@ -291,3 +291,69 @@ do { _ = X(content: <#T##() -> _#>) // expected-error {{editor placeholder in source file}} } } + +// Make sure we reject placeholders here. +protocol TestPlaceholderRequirement { + func foo(_:_) // expected-error {{type placeholder not allowed here}} + func bar() -> _ // expected-error {{type placeholder not allowed here}} + func baz() -> [_] // expected-error {{type placeholder not allowed here}} + func qux(_: [_]) // expected-error {{type placeholder not allowed here}} + + subscript(_: _) -> Void { get } // expected-error {{type placeholder not allowed here}} + subscript() -> _ { get } // expected-error {{type placeholder not allowed here}} +} + +func testPlaceholderFn1(_:_) {} // expected-error {{type placeholder may not appear in top-level parameter}} +func testPlaceholderFn2() -> _ {} // expected-error {{type placeholder may not appear in function return type}} + +var testPlaceholderComputed1: _ { 0 } // expected-error {{type placeholder not allowed here}} +var testPlaceholderComputed2: [_] { [0] } // expected-error {{type placeholder not allowed here}} + +struct TestPlaceholderSubscript { + // FIXME: Shouldn't diagnose twice. + subscript(_: _) -> Void { () } // expected-error 2{{type placeholder may not appear in top-level parameter}} + subscript(_: [_]) -> Void { () } // expected-error 2{{type placeholder may not appear in top-level parameter}} + subscript() -> _ { () } // expected-error {{type placeholder not allowed here}} + subscript() -> [_] { [0] } // expected-error {{type placeholder not allowed here}} +} + +enum TestPlaceholderInEnumElement { + case a(_) // expected-error {{type placeholder may not appear in top-level parameter}} + case b([_]) // expected-error {{type placeholder may not appear in top-level parameter}} +} + +@freestanding(expression) macro testPlaceholderMacro(_ x: _) -> String = #file +// expected-error@-1 {{type placeholder may not appear in top-level parameter}} + +@freestanding(expression) macro testPlaceholderMacro(_ x: [_]) -> String = #file +// expected-error@-1 {{type placeholder may not appear in top-level parameter}} + +@freestanding(expression) macro testPlaceholderMacro() -> _ = #file +// expected-error@-1 {{type placeholder not allowed here}} + +// Make sure we can use decls with placeholders in their interface type. +func usePlaceholderDecls( + _ fromProto: some TestPlaceholderRequirement, _ hasSubscript: TestPlaceholderSubscript +) { + _ = optInt + + _ = testPlaceholderComputed1 + _ = testPlaceholderComputed2 + + fromProto.foo(0) + _ = fromProto.bar() + _ = fromProto.baz() + fromProto.qux([]) + fromProto[0] + + _ = hasSubscript[0] + + _ = TestPlaceholderInEnumElement.a(0) + _ = TestPlaceholderInEnumElement.b([]) + + _ = #testPlaceholderMacro(0) + _ = #testPlaceholderMacro([]) + + _ = testPlaceholderFn1(0) + _ = testPlaceholderFn2() +} diff --git a/test/decl/ext/extensions.swift b/test/decl/ext/extensions.swift index 11d856702e22b..3835fe1bad9cc 100644 --- a/test/decl/ext/extensions.swift +++ b/test/decl/ext/extensions.swift @@ -402,3 +402,5 @@ extension BitwiseCopyable {} // expected-error {{cannot extend protocol 'Bitwise @_marker protocol MyMarkerProto {} extension MyMarkerProto {} // OK + +extension _ {} // expected-error {{cannot extend a type that contains placeholders}} diff --git a/test/decl/func/typed_throws.swift b/test/decl/func/typed_throws.swift index d753b454c1d54..6a3282621c12f 100644 --- a/test/decl/func/typed_throws.swift +++ b/test/decl/func/typed_throws.swift @@ -216,3 +216,8 @@ struct NotAnError {} func badThrowingFunctionType(_: () throws(NotAnError) -> ()) {} // expected-error@-1 {{thrown type 'NotAnError' does not conform to the 'Error' protocol}} + +struct GenericError: Error {} + +func placeholderThrowing1() throws(_) {} // expected-error {{type placeholder not allowed here}} +func placeholderThrowing2() throws(GenericError<_>) {} // expected-error {{type placeholder not allowed here}} diff --git a/test/expr/closure/typed_throws.swift b/test/expr/closure/typed_throws.swift index 26500dd2b2bb8..29b0e8d0b8875 100644 --- a/test/expr/closure/typed_throws.swift +++ b/test/expr/closure/typed_throws.swift @@ -8,6 +8,8 @@ enum MyBadError { case fail } +struct GenericError: Error {} + func testClosures() { let c1 = { () throws(MyError) in throw .fail @@ -36,5 +38,8 @@ func testClosures() { let c2 = { throw MyError.fail } let _: Int = c2 // expected-error@-1{{cannot convert value of type '() throws -> ()'}} + + _ = { () throws(_) in } // expected-error {{type placeholder not allowed here}} + _ = { () throws(GenericError<_>) in } // expected-error {{type placeholder not allowed here}} } diff --git a/test/stmt/typed_throws.swift b/test/stmt/typed_throws.swift index 00451c0eedd29..be7eeb39d502d 100644 --- a/test/stmt/typed_throws.swift +++ b/test/stmt/typed_throws.swift @@ -12,6 +12,8 @@ case dogAteIt case forgot } +struct GenericError: Error {} + func processMyError(_: MyError) { } func doSomething() throws(MyError) { } @@ -418,3 +420,12 @@ func testSequenceExpr() async throws(Never) { try true ? 0 : try! getInt() ~~~ getInt() // expected-error@-1 {{'try!' following conditional operator does not cover everything to its right}} } + +func testPlaceholder() { + do throws(_) {} catch {} + // expected-error@-1 {{type placeholder not allowed here}} + // expected-warning@-2 {{'catch' block is unreachable because no errors are thrown in 'do' block}} + do throws(GenericError<_>) {} catch {} + // expected-error@-1 {{type placeholder not allowed here}} + // expected-warning@-2 {{'catch' block is unreachable because no errors are thrown in 'do' block}} +} diff --git a/validation-test/compiler_crashers_2/1b94fce977ad935d.swift b/validation-test/compiler_crashers_2_fixed/1b94fce977ad935d.swift similarity index 85% rename from validation-test/compiler_crashers_2/1b94fce977ad935d.swift rename to validation-test/compiler_crashers_2_fixed/1b94fce977ad935d.swift index 0e2efe3eeb7e6..c84d709a25d98 100644 --- a/validation-test/compiler_crashers_2/1b94fce977ad935d.swift +++ b/validation-test/compiler_crashers_2_fixed/1b94fce977ad935d.swift @@ -1,3 +1,3 @@ // {"kind":"typecheck","signature":"printDifferentiableAttrArguments(swift::DifferentiableAttr const*, swift::ASTPrinter&, swift::PrintOptions const&, swift::Decl const*, bool)","signatureAssert":"Assertion failed: (original && \"Must resolve original declaration\"), function printDifferentiableAttrArguments"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s func a(@differentiable _ = diff --git a/validation-test/compiler_crashers_2/88ba80199b702649.swift b/validation-test/compiler_crashers_2_fixed/88ba80199b702649.swift similarity index 87% rename from validation-test/compiler_crashers_2/88ba80199b702649.swift rename to validation-test/compiler_crashers_2_fixed/88ba80199b702649.swift index 103d835b41f57..adffa65de7acc 100644 --- a/validation-test/compiler_crashers_2/88ba80199b702649.swift +++ b/validation-test/compiler_crashers_2_fixed/88ba80199b702649.swift @@ -1,3 +1,3 @@ // {"kind":"typecheck","signature":"(anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, swift::constraints::ConstraintLocatorBuilder)","signatureAssert":"Assertion failed: (isa(Val) && \"cast() argument of incompatible type!\"), function cast"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s func a(b : ()->Void c : _->Void) { withoutActuallyEscaping(b do : c diff --git a/validation-test/compiler_crashers_2/89acda2815351ec6.swift b/validation-test/compiler_crashers_2_fixed/89acda2815351ec6.swift similarity index 86% rename from validation-test/compiler_crashers_2/89acda2815351ec6.swift rename to validation-test/compiler_crashers_2_fixed/89acda2815351ec6.swift index 910060f41bcd9..6516f97e03fd1 100644 --- a/validation-test/compiler_crashers_2/89acda2815351ec6.swift +++ b/validation-test/compiler_crashers_2_fixed/89acda2815351ec6.swift @@ -1,5 +1,5 @@ // {"kind":"typecheck","signature":"(anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder)::$_3::operator()(swift::Type, swift::Type) const","signatureAssert":"Assertion failed: (restriction == ConversionRestrictionKind::DeepEquality), function operator()"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s func a(inout _ ) var b = String a(b diff --git a/validation-test/compiler_crashers_2/ac7123f2338b128.swift b/validation-test/compiler_crashers_2_fixed/ac7123f2338b128.swift similarity index 85% rename from validation-test/compiler_crashers_2/ac7123f2338b128.swift rename to validation-test/compiler_crashers_2_fixed/ac7123f2338b128.swift index a03cccf7a3991..584bfa97f3600 100644 --- a/validation-test/compiler_crashers_2/ac7123f2338b128.swift +++ b/validation-test/compiler_crashers_2_fixed/ac7123f2338b128.swift @@ -1,5 +1,5 @@ // {"signature":"swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::optionset::OptionSet, swift::DiagnosticTransaction*)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s enum a protocol b { associatedtype c diff --git a/validation-test/compiler_crashers_2/c8563a4a60b27cf3.swift b/validation-test/compiler_crashers_2_fixed/c8563a4a60b27cf3.swift similarity index 90% rename from validation-test/compiler_crashers_2/c8563a4a60b27cf3.swift rename to validation-test/compiler_crashers_2_fixed/c8563a4a60b27cf3.swift index 355fe39c86922..97970c53ae7f2 100644 --- a/validation-test/compiler_crashers_2/c8563a4a60b27cf3.swift +++ b/validation-test/compiler_crashers_2_fixed/c8563a4a60b27cf3.swift @@ -1,5 +1,5 @@ // {"signature":"swift::CanTypeVisitor&, llvm::SmallVectorImpl&, llvm::SmallVectorImpl&)::Matcher>::MatchVisitor, bool, swift::Type, swift::Type>::visit(swift::CanType, swift::Type, swift::Type)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s protocol a { associatedtype b associatedtype c associatedtype d func e(b, c) -> d } diff --git a/validation-test/compiler_crashers_2/ce57354c94ae5aad.swift b/validation-test/compiler_crashers_2_fixed/ce57354c94ae5aad.swift similarity index 85% rename from validation-test/compiler_crashers_2/ce57354c94ae5aad.swift rename to validation-test/compiler_crashers_2_fixed/ce57354c94ae5aad.swift index 27613df52e12b..2da7a28802a31 100644 --- a/validation-test/compiler_crashers_2/ce57354c94ae5aad.swift +++ b/validation-test/compiler_crashers_2_fixed/ce57354c94ae5aad.swift @@ -1,5 +1,5 @@ // {"kind":"emit-silgen","signature":"swift::CanTypeVisitor::visit(swift::CanType)"} -// RUN: not --crash %target-swift-frontend -emit-silgen %s +// RUN: not %target-swift-frontend -emit-silgen %s protocol a { func b() -> _ } diff --git a/validation-test/compiler_crashers_2/e1f8b6a26663e9b5.swift b/validation-test/compiler_crashers_2_fixed/e1f8b6a26663e9b5.swift similarity index 87% rename from validation-test/compiler_crashers_2/e1f8b6a26663e9b5.swift rename to validation-test/compiler_crashers_2_fixed/e1f8b6a26663e9b5.swift index b419e37e724dc..5d2c71d8e5513 100644 --- a/validation-test/compiler_crashers_2/e1f8b6a26663e9b5.swift +++ b/validation-test/compiler_crashers_2_fixed/e1f8b6a26663e9b5.swift @@ -1,4 +1,4 @@ // {"signature":"swift::CanTypeVisitor::MatchVisitor, bool, swift::Type, swift::Type>::visit(swift::CanType, swift::Type, swift::Type)"} -// RUN: not --crash %target-swift-frontend -typecheck %s +// RUN: not %target-swift-frontend -typecheck %s protocol a { associatedtype b func c(_ : _ d: b } extension a { c(_ : _ d: b struct e : a diff --git a/validation-test/compiler_crashers_2/edb1d98948183f4c.swift b/validation-test/compiler_crashers_2_fixed/edb1d98948183f4c.swift similarity index 90% rename from validation-test/compiler_crashers_2/edb1d98948183f4c.swift rename to validation-test/compiler_crashers_2_fixed/edb1d98948183f4c.swift index 63f2e16f57d04..c8b280e9fe380 100644 --- a/validation-test/compiler_crashers_2/edb1d98948183f4c.swift +++ b/validation-test/compiler_crashers_2_fixed/edb1d98948183f4c.swift @@ -1,5 +1,5 @@ // {"kind":"emit-silgen","signature":"emitRawApply(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRef, swift::CanTypeWrapper, swift::optionset::OptionSet, llvm::ArrayRef, swift::SILValue, llvm::SmallVectorImpl&, swift::Lowering::ExecutorBreadcrumb)"} -// RUN: not --crash %target-swift-frontend -emit-silgen %s +// RUN: not %target-swift-frontend -emit-silgen %s protocol a { func b() -> [(_) -> Self] } diff --git a/validation-test/compiler_crashers_2_fixed/f6ae9d69266e6b1c.swift b/validation-test/compiler_crashers_2_fixed/f6ae9d69266e6b1c.swift new file mode 100644 index 0000000000000..942b6d1817182 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/f6ae9d69266e6b1c.swift @@ -0,0 +1,6 @@ +// {"kind":"typecheck","original":"0e81571d","signature":"swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget)","signatureAssert":"Assertion failed: (isValidType(type) && \"type binding has invalid type\"), function applySolution"} +// RUN: not %target-swift-frontend -typecheck %s +subscript(a: _) -> <#type#> { + a + 0 +}