Skip to content

Compiler crash using non-static suite property in exit test #82783

Open
@simonjbeaumont

Description

@simonjbeaumont

Description

The attached repro causes a compiler crash with the latest 6.2 snapshot toolchain.

Reproduction

import Testing

@Suite struct Suite {
   func helper() throws {}  // works fine if made static

    @Test func test() async throws {
        await #expect(processExitsWith: .success) {
            try self.helper()
        }
    }
}
% swiftly use 6.2-snapshot
The global default toolchain has been set to `6.2-snapshot-2025-06-27` (was 6.1.0)

% swift --version
Apple Swift version 6.2-dev (LLVM ac66248b7c45109, Swift 92fd571d0786efe)
Target: arm64-apple-macosx15.0
Build config: +assertions

% swift build --build-tests
Building for debugging...
error: compile command failed due to signal 6 (use -v to see invocation)
macro expansion #expect:1:159: error: a C function pointer cannot be formed from a closure that captures context
`- /Users/Si/work/bugs/repro-swift-testing-compiler-crash/Tests/ReproTests/ReproTests.swift:9:10: note: expanded code originates here
 5 |
 6 |     @Test func test() async throws {
 7 |         await #expect(processExitsWith: .success) {
   |               `- note: in expansion of macro 'expect' here
 8 |             try self.helper()
 9 |         }
   +--- macro expansion #expect ----------------------------------------
   | 1 | Testing.__checkClosureCall(identifiedBy: (0x7f1b845cfd307e1b,0x8f5adec8049ff8d2,0x61e8b08ffe97e157,0x357083a92c683e6c),processExitsWith: .success,performing: {
   |   |                                                                                                                                                               `- error: a C function pointer cannot be formed from a closure that captures context
   | 2 | @Sendable func $s10ReproTests0021ReproTestsswift_IfFDefMX6_14_6expectfMf_7__localfMu_() async throws {
   | 3 |   _ = unsafe try await Testing.__requiringUnsafe(Testing.__requiringTry(Testing.__requiringAwait({
   +--------------------------------------------------------------------
10 |     }
11 | }

Assertion failed: (p.isTrackingElement(op.getOpArg1()) && "Require PartitionOp's argument should already be tracked"), function apply, file PartitionUtils.h, line 1522.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
1.      Apple Swift version 6.2-dev (LLVM ac66248b7c45109, Swift 92fd571d0786efe)
2.      Compiling with the current language version
3.      While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for ReproTests)
4.      While running pass swiftlang/swift-testing#410 SILFunctionTransform "SendNonSendable" on SILFunction "@$s10ReproTests5SuiteV4testyyYaKF".
 for 'test()' (at /Users/Si/work/bugs/repro-swift-testing-compiler-crash/Tests/ReproTests/ReproTests.swift:6:11)
 #0 0x000000010657193c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1059d593c)
 swiftlang/swift-testing#1 0x0000000106570068 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1059d4068)
 swiftlang/swift-testing#2 0x0000000106571f84 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1059d5f84)
 swiftlang/swift-testing#3 0x0000000188028624 (/usr/lib/system/libsystem_platform.dylib+0x1804ac624)
 swiftlang/swift-testing#4 0x0000000187fee88c (/usr/lib/system/libsystem_pthread.dylib+0x18047288c)
 swiftlang/swift-testing#5 0x0000000187ef7c60 (/usr/lib/system/libsystem_c.dylib+0x18037bc60)
 swiftlang/swift-testing#6 0x0000000187ef6eec (/usr/lib/system/libsystem_c.dylib+0x18037aeec)
 swiftlang/swift-testing#7 0x00000001065a745c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x105a0b45c)
 swiftlang/swift-testing#8 0x0000000101564ca0 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1009c8ca0)
 swiftlang/swift-testing#9 0x0000000101565938 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1009c9938)
swiftlang/swift-testing#10 0x000000010156523c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1009c923c)
swiftlang/swift-testing#11 0x00000001015663d0 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1009ca3d0)
swiftlang/swift-testing#12 0x000000010179dde8 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c01de8)
swiftlang/swift-testing#13 0x000000010179c384 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c00384)
swiftlang/swift-testing#14 0x00000001017c0b48 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c24b48)
swiftlang/swift-testing#15 0x00000001017c186c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c2586c)
swiftlang/swift-testing#16 0x00000001017c4054 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c28054)
#17 0x00000001017bea8c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c22a8c)
swiftlang/swift-testing#18 0x00000001017bea0c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c22a0c)
swiftlang/swift-testing#19 0x00000001017e41f0 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c481f0)
swiftlang/swift-testing#20 0x00000001017c5bfc (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c29bfc)
swiftlang/swift-testing#21 0x00000001017bec7c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c22c7c)
swiftlang/swift-testing#22 0x00000001017c71d0 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100c2b1d0)
swiftlang/swift-testing#23 0x000000010106d258 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x1004d1258)
swiftlang/swift-testing#24 0x0000000100e2d228 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100291228)
swiftlang/swift-testing#25 0x0000000100e2c888 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100290888)
swiftlang/swift-testing#26 0x0000000100e3904c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x10029d04c)
swiftlang/swift-testing#27 0x0000000100e2e680 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100292680)
swiftlang/swift-testing#28 0x0000000100e2de3c (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100291e3c)
swiftlang/swift-testing#29 0x0000000100bd1d18 (/Users/Si/Library/Developer/Toolchains/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-06-27-a.xctoolchain/usr/bin/swift-frontend+0x100035d18)
swiftlang/swift-testing#30 0x0000000187c4eb98

error: fatalError

Expected behavior

More informative compiler warning.

Environment

% swift --version
Apple Swift version 6.2-dev (LLVM ac66248b7c45109, Swift 92fd571d0786efe)
↳ Testing Library Version: 6.2 (9ebfc4ebbb2840d)

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions