Skip to content
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

Value can not be on the left-hand side of += or friends #86

Open
xffxff opened this issue Jan 20, 2022 · 2 comments
Open

Value can not be on the left-hand side of += or friends #86

xffxff opened this issue Jan 20, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@xffxff
Copy link
Member

xffxff commented Jan 20, 2022

#83 added support for += and friends (see #69), but value can not be on the left-hand side of +=.
The following test should get a validation error, as foo() is a value, not a place in memory

fn foo() {
    1
}

async fn main() {
    foo() += 2
}
@nikomatsakis
Copy link
Member

(Note: I think it can get a validation error but continue to execute and compile just as it does not; I assume that it compiles to a temporary which gets modified.)

@xffxff xffxff added the enhancement New feature or request label May 15, 2022
@Aadamandersson
Copy link
Member

I think this can be closed.
It looks like a validation error was added for this in #148. (Commit: #e05bd7166ad7b380cd171fc2f7b8666343bf65ad)

_ => {
let _ = self.validate_expr(expr);
let ErrorReported = dada_ir::error!(
self.span(expr),
"you can only assign to local variables and fields, not arbitrary expressions",
)
.emit(self.db);
self.add(validated::ExprData::Error, expr)
}

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

No branches or pull requests

3 participants