Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/BuilderTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
36 changes: 36 additions & 0 deletions test/Sema/issue-85837.swift
Original file line number Diff line number Diff line change
@@ -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<T>(first: T) -> (T) {
return first
}

public static func buildPartialBlock<each A, B>(accumulated: (repeat each A), next: B) -> (repeat each A, B) {
return (repeat each accumulated, next)
}
}

func builder<each A>(@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"
}
*/