Open Chriscbr opened 11 months ago
Maybe we can see whether it's possible to reassign to struct fields without introducing holes in the language's mutability model, or we should change the error message to "Struct fields are not reassignable" for now.
Perhaps we should rename this issue to "struct mutablity" instead of "struct reassignablity".
We discussed the idea of adding a mut
keyword to denote that a type is mutable, so instead of: MutArray
or MutMap
you would use mut Array
and mut Map
.
Then, I would use mut
for structs like so:
struct Foo { name: str };
let foo = mut Foo { name: "hello" };
foo.name = "bang";
Hi,
This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!
I tried this:
Reassigning a field of a struct
This happened:
I expected this:
The error says to try adding "var" in front, but the language doesn't currently allow individual struct fields to be labeled "var", so the error needs to be fixed.
Is there a workaround?
No response
Anything else?
No response
Wing Version
0.53.0
Node.js Version
20.9.0
Platform(s)
MacOS
Community Notes