swiftlang / swiftlang/swift

A freestanding expression macro that expands to/contains `#isolation` macro, crashes the compiler when put as a default argument

Open
#90,944 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash triage needed
Dominant language
Swift
Stars
70.4k
Forks
10.8k
PR merge metrics
PR metrics pending

Description

Description

No response

Reproduction
Implementation
struct SomeMacro1: ExpressionMacro {
    static func expansion(of _: some FreestandingMacroExpansionSyntax, in _: some MacroExpansionContext) throws -> ExprSyntax { "#isolation" }
}

@main
struct TestMacroPlugin: CompilerPlugin {
    let providingMacros: [Macro.Type] = [
        SomeMacro1.self,
    ]
}
Client
@freestanding(expression)
public macro someMacro() -> Any = #externalMacro(module: "TestMacros", type: "SomeMacro1")

@MainActor
func foo() {
    bar()
}

func bar(thing: Any = #someMacro) {
    print(thing)
}
Stack dump
1.	Apple Swift version 6.3.3 (swift-6.3.3-RELEASE)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/x/Xcode/TestMacro/Sources/Test/Test.swift")
4.	While silgen emitFunction SIL function "@$s4Test3fooyyF".
 for 'foo()' (at /Users/x/Xcode/TestMacro/Sources/Test/Test.swift:10:1)
 #0 0x000000010ddc2598 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x106066598)
 #1 0x000000010ddc0703 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x106064703)
 #2 0x000000010ddc30a6 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1060670a6)
 #3 0x00007ff81673c31d (/usr/lib/system/libsystem_platform.dylib+0x7ff801f0c31d)
 #4 0x0000000000000000
 #5 0x000000010875bf77 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009fff77)
 #6 0x000000010874a891 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009ee891)
 #7 0x000000010875c6f1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a006f1)
 #8 0x000000010874a8a1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009ee8a1)
 #9 0x000000010875c6f1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a006f1)
#10 0x000000010874a8a1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009ee8a1)
#11 0x000000010875374e (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009f774e)
#12 0x000000010874a7dd (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009ee7dd)
#13 0x000000010874084d (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009e484d)
#14 0x00000001086e9f0e (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10098df0e)
#15 0x00000001086d80a1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10097c0a1)
#16 0x00000001086e84d7 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10098c4d7)
#17 0x00000001086f4e3d (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100998e3d)
#18 0x00000001086f4560 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100998560)
#19 0x00000001086dcde4 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100980de4)
#20 0x00000001086da72e (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10097e72e)
#21 0x000000010874a6c1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009ee6c1)
#22 0x0000000108740e42 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009e4e42)
#23 0x00000001087e05b9 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a845b9)
#24 0x00000001087ded65 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a82d65)
#25 0x00000001087698f3 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a0d8f3)
#26 0x00000001086c6ff3 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10096aff3)
#27 0x00000001086c7bd2 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10096bbd2)
#28 0x00000001086c54db (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1009694db)
#29 0x00000001086cab73 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10096eb73)
#30 0x00000001086cb1c3 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10096f1c3)
#31 0x00000001087de6e1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a826e1)
#32 0x00000001087de5ee (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100a825ee)
#33 0x00000001086cf199 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x100973199)
#34 0x00000001086cb828 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x10096f828)
#35 0x0000000108020751 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002c4751)
#36 0x00000001080257d7 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002c97d7)
#37 0x00000001080224e8 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1002c64e8)
#38 0x0000000107d904b1 (/Users/x/Library/Developer/Toolchains/swift-6.3.3-RELEASE.xctoolchain/usr/bin/swift-frontend+0x1000344b1)
#39 0x00007ff81635e530
Expected behavior

It should compile without an issue.

Environment

Apple Swift version 6.3.3 (swift-6.3.3-RELEASE)
Target: x86_64-apple-macosx15.0

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash using the freestanding expression macro and default argument shown in the issue, compiling the client in Test.swift with Apple Swift 6.3.3. Trace the ASTLoweringRequest and SIL generation path reported in the stack dump; done means the same example compiles without crashing.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.