-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Wrapping value in noop function call changes evaluation order #15384
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
cc me |
Triage: still a bug. |
So having been linked #15300, I looked at this briefly. There's an argument to be made that the second behaviour is correct and the first not. What we do for non-overloaded binops is translate the LHS, then the RHS then translate the operation. Makes sense, right? Well a identifier expression is translated to an "lvalue datum", which is just a pointer to the on-stack location of the value the variable contains. We don't actually load the value from the lvalue until after translating both sides, meaning any changes to It'd be a simple fix to load the value a little earlier, but it does change visible behaviour (though you could argue that this is buggy behaviour). |
Triage: I could not reproduce the bug. I had to change the fn foo(_: (), x: isize) -> isize { x }
fn main() {
let mut a = 2isize;
println!("{}", a * foo(a = 5, a)); // 10
a = 2isize;
println!("{}", foo((), a) * foo(a = 5, a)); // 10
} |
I fixed it. |
feat: Prioritize import suggestions based on the expected type Hi, this is a draft PR to solve rust-lang#15384. `Adt` types work and now I have a few questions :) 1. What other types make sense in this context? Looking at [ModuleDef](https://github.com/rust-lang/rust-analyzer/blob/05666441bafd6010787a4097a6bd44266ad21018/crates/hir/src/lib.rs#L275) I am thinking everything except Modules. 2. Is there an existing way of converting between `ModeuleDef` and `hir::Type` in the rustanalyzer code base? 3. Does this approach seem sound to you? Ups: Upon writing this I just realised that the enum test is invalided as there are no enum variants and this no variant is passed as a function argument.
Breaking out of #15300. These two differ in evaluation order, even though the only difference is the introduction of the noop
foo((), ...)
around thea
on the LHS:http://is.gd/zVdDoh
The text was updated successfully, but these errors were encountered: