Bug 10608 – std.typecons.RefCounted has very poor diagnostics

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-11T05:06:00Z
Last change time
2013-09-18T22:28:52Z
Keywords
pull
Assigned to
andrej.mitrovich
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2013-07-11T05:06:19Z
Example 1, passing too many arguments to the ctor: ----- import std.typecons; struct S { this(int x, int y) { _data = typeof(_data)(x, y); } struct T { this(int x) { } } RefCounted!T _data; } void main() { } ----- $ dmd test.d > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3673): Error: static assert (2u == 1u) is false > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(3362): instantiated from here: emplace!(T, int, int) > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(3412): instantiated from here: initialize!(int, int) > test.d(9): instantiated from here: __ctor!(int, int) Example 2, passing too few arguments to the ctor: ----- import std.typecons; struct S { this(int x) { _data = typeof(_data)(x); } struct T { this(int x, int y) { } } RefCounted!T _data; } void main() { } ----- $ dmd test.d > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\conv.d(3676): Error: cannot implicitly convert expression (_param_1) of type int to T > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(3362): Error: template instance std.conv.emplace!(T, int) error instantiating > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(3412): instantiated from here: initialize!(int) test.d(9): instantiated from here: __ctor!(int) > C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(3412): Error: template instance std.typecons.RefCounted!(T).RefCounted.RefCountedStore.initialize!(int) error instantiating > test.d(9): instantiated from here: __ctor!(int) > test.d(9): Error: template instance std.typecons.RefCounted!(T).RefCounted.__ctor!(int) error instantiating Example 3, accessing uninitialized payload: ----- import std.typecons; struct S { void test() { assert(_data.x == 1); } struct Payload { int x; } RefCounted!(Payload, RefCountedAutoInitialize.no) _data; } void main() { S s; s.test(); } ----- $ dmd test.d > [email protected](3507): Assertion failure
Comment #1 by andrej.mitrovich — 2013-09-18T18:10:22Z
The first two diagnostics have improved since they're now emitted in emplace. The third one is fixed in the pull. https://github.com/D-Programming-Language/phobos/pull/1586
Comment #2 by github-bugzilla — 2013-09-18T20:35:34Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/401ded61c82e7dbff38b94a44bc5fa3d092baacc Fix Issue 10608 - Better diagnostic for RefCounted assert. https://github.com/D-Programming-Language/phobos/commit/1c8a49a989e2654a5375ae414d9927f8f35a0da6 Merge pull request #1586 from AndrejMitrovic/Fix10608 Issue 10608 - Better diagnostic for RefCounted assert.