I'm not 100% sure this is a bug, but the behavior seems very strange to me. You can write to fields of an uninitialized mutable struct.
I tried this code:
struct X { }
struct Y {
x : X ,
}
fn main ( ) {
let mut y:Y;
y.x = X{}; // this line compiles
// y.x; // this line would throw an error
}
I expected to see this happen: the assignment throws a compiler error.
Instead, this happened: no error is generated.
Alternatively, it would be ok to have the assignment work, but then I'd expect to be able to refer to it, like in the line below it.
Link to playground
I'm not 100% sure this is a bug, but the behavior seems very strange to me. You can write to fields of an uninitialized mutable struct.
I tried this code:
I expected to see this happen: the assignment throws a compiler error.
Instead, this happened: no error is generated.
Alternatively, it would be ok to have the assignment work, but then I'd expect to be able to refer to it, like in the line below it.
Link to playground