-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Wrong error message trying to initialise an empty struct #3192
Comments
Parsing happens before typechecking, and the "at least one field" error is a type error. So this won't change. We discussed it a while ago and agreed to disallow empty structs, but if you want to reopen the discussion, feel free to file a separate RFC bug. |
@catamorphism Maybe the parser could allow |
Sorry, I was reading too fast and didn't understand at first that the parser is essentially checking for the same thing that the typechecker is. That seems reasonable to me. |
I attempted to fix this. Something like (libsyntax/parse/parse.rs):
But it seems like this makes the grammar ambiguous with empty-bodied 'do' statements -- I wonder if this will stop being ambiguous once type names have to be camel case? |
Type names will never have to be camel case---that's intended to be a convention. I think that's a known ambiguity that was supposed to be resolved by
Which, admittedly, is not so bad. |
it occurred to me that the grammar might not have to be ambiguous after all, and it was just my fix that was wrong. we have something like:
and |
I think this bug is just asking for a better parser error message when you try to create an empty structure. That doesn't seem backwards incompatible to me. Renominating. |
just a bug, removing milestone/nomination. |
Visiting for triage email from 2013-07-29. I think I can revise the parser in a disciplined manner to put in a better error message (as pcwalton suggested). I spent some time Monday hacking on that, I'll have a draft up for people to look at soon. |
reopening as reminder that I need to go back and fix up PR #8467 |
…ure (which may be worth factoring out).
Implement x86 AVX intrinsics ~Blocked on <https://github.com/rust-lang/miri/pull/3214>~
Our `Cargo.lock` uses https://crates.io/crates/libc/0.2.154, which has been yanked. Do a `cargo update` to use a different version. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
Updated bug report
Compiling this (erroneous) program:
yields:
We currently emit a nice error message if you incorrectly write the
struct mutex
definition as:that tells you that you need to write the Unit-like struct as
struct mutex;
; we should do the same for the struct initialization expression.Original bug report
gives:
but if you comment out the
let x
line, it gives:Personally, I think we should be allowed to have empty structs, but either way, the latter error message should have higher priority(?) than the former.
The text was updated successfully, but these errors were encountered: