Skip to content
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

Macro expression reuse causes invalid behavior #8852

Closed
darkf opened this issue Aug 29, 2013 · 2 comments
Closed

Macro expression reuse causes invalid behavior #8852

darkf opened this issue Aug 29, 2013 · 2 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@darkf
Copy link
Contributor

darkf commented Aug 29, 2013

The following code:

enum T {
    A(int),
    B(float)
}

macro_rules! test(
    ($e:expr) => (
        fn foo(a:T, b:T) -> T {
            match (a, b) {
                (A(x), A(y)) => A($e),
                (B(x), B(y)) => B($e),
                _ => fail!()
            }
        }
    )
)

test!(x + y)

fn main() {
    foo(A(1), A(2));
}

Yields the following type error:

y.rs:18:6: 18:11 error: mismatched types: expected `int` but found `float` (expected int but found float)
y.rs:18 test!(x + y)
              ^~~~~
error: aborting due to previous error

Which is wrong, as the expression should be expanded into both locations, both xs and ys having separate types.

@jdm
Copy link
Contributor

jdm commented Aug 29, 2013

Probably #6000 again.

@huonw
Copy link
Member

huonw commented Sep 7, 2013

Seems similar to #8754 too.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Sep 7, 2013
…node has a

unique id. Fixes numerous bugs in macro expansion and deriving. Add two
representative tests.

Fixes rust-lang#7971
Fixes rust-lang#6304
Fixes rust-lang#8367
Fixes rust-lang#8754
Fixes rust-lang#8852
bors added a commit that referenced this issue Sep 10, 2013
…r=catamorphism

Ensures that each AST node has a unique id. Fixes numerous bugs in macro expansion and deriving. Add two
representative tests.

Fixes #7971
Fixes #6304
Fixes #8367
Fixes #8754
Fixes #8852
Fixes #2543
Fixes #7654
xFrednet pushed a commit to xFrednet/rust that referenced this issue May 21, 2022
… r=Manishearth

Lint indirect usages in `disallowed_methods`

Fixes rust-lang#8849

changelog: Lint indirect usages in [`disallowed_methods`]
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
3 participants