Bug 21170 – Can not instantiate a class instance using inout constructor.
Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-17T09:13:28Z
Last change time
2022-01-04T10:06:30Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
alexandru.ermicioi
Comments
Comment #0 by alexandru.ermicioi — 2020-08-17T09:13:28Z
Kinda silly that you can't create mutable/immutable objects using inout constructor. For some reason const one works.
Example:
-----
import std;
class Silly {
this() inout {
}
}
void main()
{
auto s = new Silly();
auto cs = new const Silly();
auto iss = new immutable Silly();
}
-----
Error:
-----
onlineapp.d(10): Error: inout constructor onlineapp.Silly.this creates inout object, not mutable
onlineapp.d(12): Error: inout constructor onlineapp.Silly.this creates inout object, not immutable
-----
Expected:
first & second error to not be at all here, since those are also part of inout constructor's job.
Comment #1 by pro.mathias.lang — 2022-01-04T10:06:30Z
Annoying bug, but long known, see the related bug.
*** This issue has been marked as a duplicate of issue 10013 ***