Skip to content

Swift 5.9 macro declarations are dropped entirely (and #name calls are lost) #4551

Closed

Description

@rajatnagda45

Version

v8 @ 0.9.92 (86c57be)

Problem

Swift 5.9 macros never enter the graph. macro stringify(...) = #externalMacro(...) parses as a macro_declaration (freestanding or attached), which is in neither the Swift function_types nor class_types, so the whole declaration is dropped — the symbol is invisible. A freestanding call site #stringify(...) parses as a macro_invocation (not a call_expression), so its call edge is lost too.

Reproduce

from graphify.extract import extract_swift
# macro stringify<T>(_ v: T) -> (T, String) = #externalMacro(module: "M", type: "S")
# func use() { let x = #stringify(1 + 1) }

The stringify macro node is absent and use() -> stringify is not an edge.

Expected vs actual

  • Expected: the macro declaration is a node; a freestanding #name(...) call resolves to it; calls inside the macro's arguments still resolve.
  • Actual: declaration dropped; invocation unresolved.

Notes

macro_declaration has no name field — the name is a bare simple_identifier child (already covered by Swift's name_fallback_child_types). Attached-macro usage (@AddCompletion on a type) is an attribute, not a macro_invocation, and can stay unresolved (fail-closed).

Activity

  1. github-actions commented on Oct 18, 2026

    @github-actions

    Thanks for opening this issue, @rajatnagda45. A maintainer will take a look soon.

    If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.

    To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.

  2. safishamsi commented on Oct 20, 2026

    @safishamsi
    Member

    Fixed in 0.9.93 by #4555. Swift macro declarations are extracted and macro calls resolve. Thanks @rajatnagda45 for the report. Live on PyPI: https://pypi.org/project/graphifyy/0.9.93/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions