Skip to content

Check LHS expression of assignment #10123

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

Merged
merged 2 commits into from
Oct 30, 2013
Merged

Check LHS expression of assignment #10123

merged 2 commits into from
Oct 30, 2013

Conversation

klutzy
Copy link
Contributor

@klutzy klutzy commented Oct 28, 2013

This patch fixes rustc to emit explicit error if LHS of assignment is
not allowed.

Fixes #7507
Fixes #7508

@alexcrichton
Copy link
Member

I have a feeling that this code doesn't belong in resolve, but rather somewhere in the middle of typechecking. I'm not entirely sure where it belongs in that code, however, although @nikomatsakis may have a better idea than I do.

@adrientetar
Copy link
Contributor

Does it mean that we can't do tuple alloc as in Python?
That'd be cool to have as a feature.

@nikomatsakis
Copy link
Contributor

Definitely not resolve. typeck seems like a suitable place (there are various options, but resolve is strictly for name resolution). It can re-use the existing routine ty::expr_is_lval.

@klutzy
Copy link
Contributor Author

klutzy commented Oct 30, 2013

They are now in typeck/check/mod.rs.
Note: expr_is_lval thinks None is not lvalue, so None = Some(1) now produces different error message. (was: "cannot assign to immutable static item")

@adridu59 (a, b) = ... is unimplemented now, so this patch is just to produce a proper error rather than ICE.
There is some discussion at #7507, and we could open a RFC issue for the cool feature.

bors added a commit that referenced this pull request Oct 30, 2013
This patch fixes rustc to emit explicit error if LHS of assignment is
not allowed.

Fixes #7507
Fixes #7508
@bors bors closed this Oct 30, 2013
@bors bors merged commit cab0045 into rust-lang:master Oct 30, 2013
@klutzy klutzy deleted the fix-7507 branch November 16, 2013 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants