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
Comment #5 by github-bugzilla — 2013-09-18T21:53:46Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/1ecb4525bfb3b2d76c78e0b1d5c6a822e2411a02 Fixes Issue 10099 - Better diagnostic for a disabled default constructor. https://github.com/D-Programming-Language/dmd/commit/6380eae1fd53cdcb5a576e7572bc9349d9b95467 Merge pull request #2572 from AndrejMitrovic/Fix10099 Issue 10099 - Better diagnostic for a disabled default constructor.