Skip to content

Nested macro invocation doesn't follow proper scoping rules #9323

Closed
@lilyball

Description

@lilyball

When one macro invokes another macro, it always looks up the nested macro from the point of the outer invocation, instead of from the point of the macro definition. I don't know if this is intentional.

Example:

fn main() {
    macro_rules! foo(
        () => (println!("outer"))
    );
    {
        macro_rules! bar(
            () => (foo!())
        );
        {
            macro_rules! foo(
                () => (println!("inner"))
            );
            bar!()
        }
    }
}

If these were functions, it would print outer, but instead it prints inner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions