funct7
funct7

Reputation: 3591

Swift macro declaration not available in scope

I have a Swift Macro that does the following:

assertMacroExpansion(
    #"""
    struct MyStruct { var count: Int }
    let obj = MyStruct(count: 42)
    #destr(obj, \.count)
    """#,
    expandedSource:
    #"""
    struct MyStruct { var count: Int }
    let obj = MyStruct(count: 42)
    let count = obj[keyPath: \.count]
    """#,
    macros: testMacros)

The test passes, and expanding the macro in "main.swift" yields the desired result. However, I get the compiler error that the constant with the identifier cannot be found in scope like so:

Declaration generated through macro is not available in scope

I have found this Github Issue that may be related to the issue I'm experiencing.

Is this possibly a bug or am I doing something wrong?

Upvotes: 1

Views: 212

Answers (0)

Related Questions