Skip to content

|| true after macro invocation in StmtExpr parses oddly #19658

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

Closed
tomjakubowski opened this issue Dec 9, 2014 · 1 comment
Closed

|| true after macro invocation in StmtExpr parses oddly #19658

tomjakubowski opened this issue Dec 9, 2014 · 1 comment

Comments

@tomjakubowski
Copy link
Contributor

For example:

#![feature(macro_rules)]

macro_rules! foo { () => { true } }

fn baz() -> bool {
    foo!() || true
}

fn main() { }

When compiled, produces these errors:

foo.rs:3:28: 3:32 error: mismatched types: expected `()`, found `bool` (expected (), found bool)
foo.rs:3 macro_rules! foo { () => { true } }
                                    ^~~~
foo.rs:3:1: 3:36 note: in expansion of foo!
foo.rs:6:5: 6:14 note: expansion site
foo.rs:6:12: 6:19 error: mismatched types: expected `bool`, found `|| -> bool` (expected bool, found fn)
foo.rs:6     foo!() || true
                    ^~~~~~~
error: aborting due to 2 previous errors

Whereas something like this does parse as intended:

#![feature(macro_rules)]

macro_rules! foo { () => { true } }

fn main() {
    if foo!() || true {

    }
}

The error is remedied by surrounding the whole expression in parentheses, turning it into a return statement, or doing something like let x = foo!() || true; x.

@tomjakubowski tomjakubowski changed the title || true after macro invocation in StmtExpr parses as a closure || true after macro invocation in StmtExpr parses oddly Dec 9, 2014
@tomjakubowski
Copy link
Contributor Author

closing because this ought to be fixed by #18958

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant