Closed
Description
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 x
s and y
s having separate types.