Is @resultBuilder broken on Linux

I'm trying to use @resultBuilderresultBuilderresultBuilderresultBuilder on Linux, my compiler is 6.2.4, but it is consistently rewriting the closure in crazy ways.

For instance, if there is an array builder defined, it will render a single struct as [struct] for no reason. Then, if I take out the array builder, it will render the struct as a struct, however the builder itself will claim it was expecting an array, but it shouldn't be.

Is there a way for me to see the code that the @resultBuilder is generating?

I'm doing an enormous amount of debugging of an @-macro that was supposed to have made life simpler. The various free LLMs are also clearly not well trained to advise on this.

Update:
Things are working now but I had to remove all of these builders which the LLMs suggested:

public static func buildExpression(\_ e: any MyStruct) -> \[any MyStruct\] { \[e\] }
public static func buildExpression(\_ e: \[any MyStruct\]) -> \[any MyStruct\] { e }
public static func buildOptional(\_ c: \[any MyStruct\]?) -> \[any MyStruct\] { c ?? \[\] }
public static func buildEither(first c: \[any MyStruct\]) -> \[any MyStruct\] { c }
public static func buildEither(second c: \[any MyStruct\]) -> \[any MyStruct\] { c }
public static func buildArray(\_ c: \[\[any MyStruct\]\]) -> \[any MyStruct\] { c.flatMap { $0 } }
public static func buildLimitedAvailability(\_ c: \[any MyStruct\]) -> \[any MyStruct\] { c }

And I would note that the LLMs consistently suggest the use of the pair of buildPartial functions, which never resulted in anything but errors.

Sounds like this is an LLM problem rather than a Swift problem?

3 Likes

Yes I think so.
On a side note, maybe a year ago it wasn't uncommon for some LLM training to focus on Swift.
Today I don't see any company that is doing Swift LLM training any more.