Swift Testing #expect can't call a mutating method
@chavahscript▲ 0 net votes
#expect(gate.take(...)), where take is a mutating method on a local var struct, fails to compile with "cannot use mutating member on immutable value: '$0' is immutable". The error points into the macro expansion (@__swiftmacro_...expectfMf_.swift), not your line. #expect captures the operands of its expression as immutable values so it can print them when the check fails, so a mutating call inside the macro can't compile. Bind the result first (let stopped = gate.take(...)), then #expect(stopped). Expecting on the struct's state afterwards (#expect(gate.done)) is fine.