From 0feacec63b73b61088944205ab27dcb147d650d7 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Fri, 7 Nov 2025 16:17:55 +0000 Subject: [PATCH] [CS] Fix an over-eager assert We can in fact have placeholders here if the type is bound to a hole. --- lib/Sema/CSSyntacticElement.cpp | 3 +-- ...cElementConstraintGenerator-visitDecl-8830af.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 validation-test/compiler_crashers_fixed/SyntacticElementConstraintGenerator-visitDecl-8830af.swift diff --git a/lib/Sema/CSSyntacticElement.cpp b/lib/Sema/CSSyntacticElement.cpp index e90859f7805ba..9fb95156411d9 100644 --- a/lib/Sema/CSSyntacticElement.cpp +++ b/lib/Sema/CSSyntacticElement.cpp @@ -803,8 +803,7 @@ class SyntacticElementConstraintGenerator auto projectedTy = computeProjectedValueType(wrappedVar, wrapperTy); // The projected type may have an error, make sure we turn it into a hole // if necessary. - ASSERT(!projectedTy->hasUnboundGenericType() && - !projectedTy->hasPlaceholder()); + ASSERT(!projectedTy->hasUnboundGenericType()); projectedTy = cs.replaceInferableTypesWithTypeVars(projectedTy, locator); cs.setType(projectedVal, projectedTy); } diff --git a/validation-test/compiler_crashers_fixed/SyntacticElementConstraintGenerator-visitDecl-8830af.swift b/validation-test/compiler_crashers_fixed/SyntacticElementConstraintGenerator-visitDecl-8830af.swift new file mode 100644 index 0000000000000..0bb9336472d95 --- /dev/null +++ b/validation-test/compiler_crashers_fixed/SyntacticElementConstraintGenerator-visitDecl-8830af.swift @@ -0,0 +1,11 @@ +// {"kind":"typecheck","original":"25782df5","signature":"(anonymous namespace)::SyntacticElementConstraintGenerator::visitDecl(swift::Decl*)","signatureAssert":"Assertion failed: (!projectedTy->hasUnboundGenericType() && !projectedTy->hasPlaceholder()), function setPropertyWrapperAuxiliaryTypes"} +// RUN: not %target-swift-frontend -typecheck %s +@propertyWrapper +struct a< + b +> { + projectedValue : Self var wrappedValue: b +} +{ + @a var c: <#type#> +}