Skip to content

[JuliaLowering] Provenance problem with old-style macros #491

@singularitti

Description

@singularitti

When JETLS detects an unused local binding, it renders the affected code with curly underlines. This generally behaves correctly in ordinary local scopes (e.g. inside a function body). However, when the unused binding appears inside a macro expansion, the language server applies the underline styling to the entire macro application range, rather than to the specific binding.

This results in excessive visual noise in VS Code: every line in the macro application is underlined and dimmed, even though only a single local binding is unused.

Minimal Working Example

using RecipesBase: @recipe

@recipe function a(x)
    b = 1
    return nothing
end

Here, b is unused, which is correct to flag. However, in VS Code the entire macro application range (@recipe function ... end) is rendered with curly underlines and reduced opacity, rather than pinpointing just the line defining b.

Expected Behavior

Only the exact source range corresponding to the unused local binding (b = 1) should be underlined and styled.

Actual Behavior

The full macro application range is underlined and dimmed, making the diagnostic overly broad and visually distracting.

Question / Suggestion

Is it possible for JETLS to:

  • Track the precise source location of the unused binding inside a macro expansion, and
  • Restrict the diagnostic range to that specific binding (or at least the relevant line), instead of the entire macro invocation?

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    JuliaLoweringIssues rooted from the dependency package JuliaLowering

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions