Skip to content

Impls inside of macros doesn't work #4651

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
auroranockert opened this issue Jan 26, 2013 · 2 comments
Closed

Impls inside of macros doesn't work #4651

auroranockert opened this issue Jan 26, 2013 · 2 comments
Labels
A-syntaxext Area: Syntax extensions

Comments

@auroranockert
Copy link
Contributor

For example, this doesn't work.

macro_rules! Q(($T:ty, $f:expr, $name:ident) => {
  struct $name {
    value: $T
  }

  impl $name {
    pure fn add(&self, other: &$name) -> $name {
      $name { value: self.value + other.value }
    }
  }
})

Q!(i8, 8, Q8)

fn main() {
  let a = Q8 { value: 4 };
  let b = Q8 { value: 8 };

  io::println(fmt!("Q8: %?", &a.add(&b)))
}

and gives the error,

error: type `Q8` does not implement any method in scope named `add`
io::println(fmt!("Q8: %?", &a.add(&b)))

the intended effect is something like,

Q8: {value: 12}

should be printed to stdout.

@catamorphism
Copy link
Contributor

Seems non-critical for 0.7. Nominating for milestone 1 (well-defined).

@graydon
Copy link
Contributor

graydon commented May 2, 2013

dupe of #4375

@graydon graydon closed this as completed May 2, 2013
# 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

3 participants