Bug 10099 – Diagnostic for disabled default construction should improve
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-16T19:05:00Z
Last change time
2013-09-18T21:54:01Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-05-16T19:05:06Z
-----
struct S
{
int x;
@disable this();
this(int x) { }
}
void main()
{
S s; // L12
}
-----
> test.d(12): Error: variable test.main.s initializer required for type S
This should really be:
> test.d(12): Error: struct test.S cannot be default-initialized because it has a default constructor annotated with @disable
This would be similar to:
-----
struct S
{
@disable this(this);
}
void main()
{
S s;
S s2 = s;
}
-----
> test.d(11): Error: struct test.S is not copyable because it is annotated with @disable
Comment #1 by k.hara.pg — 2013-05-18T08:04:46Z
> test.d(12): Error: struct test.S cannot be default-initialized because it has a default constructor annotated with @disable
It seems to me that is a little long message. More shorter is better.
With new expression:
struct S {
@disable this();
}
class C {
S s;
}
void main() {
auto x = new C();
}
test.d(11): Error: default construction is disabled for type C
How about using "default construction is disabled for type XXX"?
Comment #2 by andrej.mitrovich — 2013-05-18T12:17:01Z
(In reply to comment #1)
> > test.d(12): Error: struct test.S cannot be default-initialized because it has a default constructor annotated with @disable
>
> It seems to me that is a little long message. More shorter is better.
Yes, bad example. Anything is better than that "initializer required for..".
Comment #3 by andrej.mitrovich — 2013-05-18T12:17:21Z
(In reply to comment #1)
> How about using "default construction is disabled for type XXX"?
Perfect.
Comment #4 by andrej.mitrovich — 2013-09-18T18:00:41Z