-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Can't create box of parenthesised expression (documentation, error reporting) #15386
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
Comments
Yeah, if you add the parens, |
|
I'm going to mark this as missing documentation and poor error reporting, then. The |
box ... in HEAP ? |
Is it possible that this ambiguity could be resolved, at least in the majority of cases? The parser could check after parsing if box(foo) {
...
}
{
...
} would be parsed as if (box(foo) { ... }) {
...
} as it is today. I made a small patch to |
This lets the parser parse expressions like `box (1i + 2)` as `box() (1i + 2)`. Expressions are parsed greedily in `if`, `while`, and `for` expressions, so that `if box(foo) {} {}` is parsed as `if (box(foo) {}) {}`. This is the same behaviour as before this change. Closes rust-lang#15386.
Contents of
test.rs
:in 0.11.0, this yields:
However, the following code compiles:
Even doing
box (2)
is considered invalid syntax.EDIT: Apparently,
box()(2)
is valid syntax, but this isn't written down anywhere.The text was updated successfully, but these errors were encountered: