-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.