You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In below listing the assignment line I think should not compile with error like "invalid left-hand side expression" - as it would be in case variable was not a struct.
PS: Moving const definition to the function body does not change anything.
pubstructFoo{bar:bool,}constCONF:Foo = Foo{bar:false};fnmain(){println!("main 0 {}",CONF.bar);// prints false - OK// This does compile ?!?CONF.bar = true;println!("main 1 {}",CONF.bar);// prints false - ?!?}
This is working as expected – the LHS of an assignment must be a place expression, which a field access is. This should probably be warned against though, but that is covered by #16789, so closing in favor of that.
In below listing the assignment line I think should not compile with error like "invalid left-hand side expression" - as it would be in case variable was not a struct.
PS: Moving const definition to the function body does not change anything.
(Playground)
Output:
Errors:
The text was updated successfully, but these errors were encountered: