ITADN

Any macro inside protocol body crashes the compiler (again)

#91642Openatifdev10 创建于 5 天前
crashtriage needed
A
atifdev10commented
### Description Any type/variation of macro inside a protocol body causes a crash. ### Reproduction ```swift @freestanding(declaration) macro something() = #externalMacro(module: "TestMacros", type: "SomeMacro") protocol Foo { #something } ``` Macro: ```swift struct SomeMacro: DeclarationMacro { static func expansion(of: some FreestandingMacroExpansionSyntax, in: some MacroExpansionContext) throws -> [DeclSyntax] { [] } } @main struct TestMacroPlugin: CompilerPlugin { let providingMacros: [Macro.Type] = [ SomeMacro.self ] } ``` ### Stack dump ```text 1. Apple Swift version 6.5-dev (LLVM 1fe0005f2103b39, Swift 1f6442f1d1fcbb7) 2. Compiling with the current language version 3. While evaluating request PublicSymbolsRequest(Generate TBD for file "/Users/x/Xcode/TestMacro/Sources/Test/Test.swift") #0 0x000000010a609728 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x107450728) #1 0x000000010a6076a3 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10744e6a3) #2 0x000000010a60a206 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x107451206) #3 0x00007ff81620131d (/usr/lib/system/libsystem_platform.dylib+0x7ff801f0c31d) #4 0x0000000000000000 #5 0x00007ff8160e7476 (/usr/lib/system/libsystem_c.dylib+0x7ff801df2476) #6 0x00007ff8160e6698 (/usr/lib/system/libsystem_c.dylib+0x7ff801df1698) #7 0x000000010a899bc3 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1076e0bc3) #8 0x00000001041ecee3 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x101033ee3) #9 0x00000001041ec927 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x101033927) #10 0x00000001041f1eeb (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x101038eeb) #11 0x00000001041ec9e2 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1010339e2) #12 0x0000000103b0fa93 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x100956a93) #13 0x0000000103ba53bc (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1009ec3bc) #14 0x0000000103ba5f1e (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1009ecf1e) #15 0x0000000103baca1b (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1009f3a1b) #16 0x0000000103baa35c (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1009f135c) #17 0x0000000103ba5fd9 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1009ecfd9) #18 0x000000010357b279 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1003c2279) #19 0x000000010355bde6 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1003a2de6) #20 0x000000010355458b (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10039b58b) #21 0x0000000103553222 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10039a222) #22 0x000000010356886f (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x1003af86f) #23 0x0000000103558608 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10039f608) #24 0x000000010355529f (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10039c29f) #25 0x00000001031f3257 (/Users/x/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2026-08-11-a.xctoolchain/usr/bin/swift-frontend+0x10003a257) #26 0x00007ff815e23530 ``` ### Expected behavior It sohuld not crash. ### Environment Apple Swift version 6.5-dev (LLVM 1fe0005f2103b39, Swift 1f6442f1d1fcbb7) Target: x86_64-apple-macosx15.0 Build config: +assertions ### Additional information It looks like this started crashing for me again. I did not reopen the other issue because it looks like the stack dump changed. Crashes in the main and 6.4.x branch (stable releases also crash but the #88826 is not in these). Previously #88791.
0 条评论