Closed
Description
Consider this hygiene demonstration (playground):
#![feature(decl_macro)]
macro x() {
println!("x");
}
macro y() {
x!(); // This `x` identifier is in a fresh hygiene scope within `y`,
macro x() { println!("y"); } // so it resolves to this definition.
}
fn main() {
y!();
}
This prints "y"
, as expected.
However, if we 'launder' the definition macro x()
using an identity macro (playground):
#![feature(decl_macro)]
macro id($($tt:tt)*) {
$($tt)*
}
macro x() {
println!("x");
}
macro y() {
x!();
id!(macro x() { println!("y"); }); // What is the scope of this `x`?
}
fn main() {
y!();
}
We get an error that the invocation of x
is ambiguous.
Is this the expected behaviour?