Skip to content

lambda-var hygiene #9383

New issue

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

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

Already on GitHub? # to your account

Closed
jbclements opened this issue Sep 21, 2013 · 4 comments
Closed

lambda-var hygiene #9383

jbclements opened this issue Sep 21, 2013 · 4 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@jbclements
Copy link
Contributor

lambda vars and function arguments should be treated hygienically. This is a placeholder bug to attach to some xfailed tests. FWIW, I think this is not a huge amount of work.

@edwardw
Copy link
Contributor

edwardw commented Mar 25, 2014

What exactly does this ticket ask? The following already works out-of-box:

#[feature(macro_rules)];

macro_rules! macro_invoke (($ex:expr) => ({let _x = 9; $ex()}))
pub fn main() {
    let _x = 8;
    assert_eq!(macro_invoke!(|| _x),8)
}

@flaper87
Copy link
Contributor

@jbclements I couldn't find any test with #9383 in it. Does @edwardw comment address what you meant? If so, we can mark this issue as needtest.

@huonw
Copy link
Member

huonw commented Mar 25, 2014

No, it's still wrong. This is referring to function/lambda arguments. The following compiles and prints 1:

#[feature(macro_rules)];

macro_rules! wrong {
    ($e: expr) => {
        (|x| { $e })(1)
    }
}

macro_rules! right {
    ($e: expr) => {
        { let x = 1; $e }
    }
}

fn main() {
    println!("{}", wrong!(x));
    // println!("{}", right!(x));
}

(Uncommenting the right! invocation gives "unresolved name x", which the wrong! one should too.)

@jbclements
Copy link
Contributor Author

Oops, yes, closed by #15425 .

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-syntaxext Area: Syntax extensions
Projects
None yet
Development

No branches or pull requests

4 participants