diff --git a/lib/Sema/BuilderTransform.cpp b/lib/Sema/BuilderTransform.cpp index 74a74fb2b591..6a5841267ffb 100644 --- a/lib/Sema/BuilderTransform.cpp +++ b/lib/Sema/BuilderTransform.cpp @@ -1597,7 +1597,7 @@ VarDecl *ResultBuilder::buildVar(SourceLoc loc) { Identifier name = ctx.getIdentifier(("$__builder" + Twine(VarCounter++)).str()); auto var = new (ctx) - VarDecl(/*isStatic=*/false, VarDecl::Introducer::Var, loc, name, DC); + VarDecl(/*isStatic=*/false, VarDecl::Introducer::Let, loc, name, DC); var->setImplicit(); return var; } diff --git a/test/Sema/issue-85837.swift b/test/Sema/issue-85837.swift new file mode 100644 index 000000000000..8a8cc680267f --- /dev/null +++ b/test/Sema/issue-85837.swift @@ -0,0 +1,36 @@ +// RUN: %target-typecheck-verify-swift + +// Verifies fix for Github Issue #85837 +// https://github.com/swiftlang/swift/issues/85837 +// +// + +@resultBuilder public enum TupleBuilder { + public static func buildPartialBlock(first: T) -> (T) { + return first + } + + public static func buildPartialBlock(accumulated: (repeat each A), next: B) -> (repeat each A, B) { + return (repeat each accumulated, next) + } +} + +func builder(@TupleBuilder content: ()->(repeat each A)) -> (repeat each A) { + return content() +} + +// Ensure this optimally packs parameters +let built: (String, Int, String) = builder { + "a" + 2 + "c" + } + +/* +// Ideally we should be able to fall back to this legacy type? +let legacy: ((String, Int), String) = builder { + "a" + 2 + "c" +} +*/ \ No newline at end of file