Bug 7256 – std.typecons.Nullable of a const value

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-01-09T12:40:00Z
Last change time
2013-02-09T21:49:35Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-01-09T12:40:23Z
I think std.typecons.Nullable should sopport a const value too, if possible: import std.typecons: Nullable; const struct Foo {} Nullable!Foo bar() { Foo f; return Nullable!Foo(f); } void main() {} DMD 2.058 Head: ...\dmd2\src\druntime\import\object.di(454): Error: function object.TypeInfo.destroy (void* p) is not callable using argument types (const(Foo)*) ...\dmd2\src\druntime\import\object.di(454): Error: cannot implicitly convert expression (&obj) of type const(Foo)* to void* ...\dmd2\src\phobos\std\typecons.d(1188): Error: template instance object.clear!(const(Foo)) error instantiating test.d(3): instantiated from here: Nullable!(const(Foo)) ...\dmd2\src\phobos\std\typecons.d(1198): Error: can only initialize const member _value inside constructor
Comment #1 by bearophile_hugs — 2012-01-09T12:43:40Z
See also issue 7257
Comment #2 by andrej.mitrovich — 2013-02-09T21:49:35Z
Fixed in 2.059.