-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
placement new inout
issue
#21160
Comments
@WalterBright I think this is a bug? |
An inout object cannot be modified, but you're assigning it to a mutable The compiler is behaving correctly. |
The input is mutable People always write |
We mark copy constructors |
Okay, I just realised that this works: class C
{
this(inout int) inout; // const-ness matches SECOND arg
}
void test()
{
C c1 = new C(10); // `10` is mutable so `this` is mutable
} Obviously This is interesting to think about though; we find |
This error seems wrong; the constructor signature doesn't determine the cost-ness of the constructed object; the argument does (in this case, it's a
C
)Think this should work. It is conventional for constructors to be
inout
.The text was updated successfully, but these errors were encountered: