Skip to content

Hygiene problem in nested macros using ":pat" bindings #15221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbclements opened this issue Jun 27, 2014 · 0 comments
Closed

Hygiene problem in nested macros using ":pat" bindings #15221

jbclements opened this issue Jun 27, 2014 · 0 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@jbclements
Copy link
Contributor

A nested macro expansion using :pat bindings is getting expanded into something where
a binding doesn't capture a varref that it should. Here's the code:

#![feature(macro_rules)]

macro_rules! inner_bind (
    ( $p:pat, $id:ident) => ({let $p = 13; $id}))

macro_rules! outer_bind (
    ($p:pat, $id:ident ) => (inner_bind!($p, $id)))

fn main() {
        outer_bind!(g1,g1);
}

Working on this now...

bors added a commit that referenced this issue Jun 28, 2014
This PR includes two big things and a bunch of little ones.

1) It enables hygiene for variables bound by 'match' expressions.
2) It fixes a bug discovered indirectly (#15221), wherein fold traversal failed to visit nonterminal nodes.
3) It fixes a small bug in the macro tutorial.

It also adds tests for the first two, and makes a bunch of small comment improvements and cleanup.
@bors bors closed this as completed in e3361bc Jun 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

2 participants