Bug 11361 – Variant fails to compile with functions/delegates that contain const parameters.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-25T18:29:00Z
Last change time
2013-10-27T14:52:46Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
opantm2+dbugs

Comments

Comment #0 by opantm2+dbugs — 2013-10-25T18:29:27Z
Example: import std.variant; const(char[]) t1(const(char[]) c) { return c; } void main() { auto fn = &t1; Variant v = fn; } Output: dmd test.d /Users/kapps/dev/dmd/phobos/std/variant.d(515): Error: can only initialize const member _expand_field_0 inside constructor /Users/kapps/dev/dmd/phobos/std/variant.d(585): Error: template instance std.variant.VariantN!(32LU).VariantN.handler!(const(char[]) function(const(char[]))) error instantiating /Users/kapps/dev/dmd/phobos/std/variant.d(535): instantiated from here: opAssign!(const(char[]) function(const(char[]) c)) test.d(9): instantiated from here: __ctor!(const(char[]) function(const(char[]) c)) /Users/kapps/dev/dmd/phobos/std/variant.d(535): Error: template instance std.variant.VariantN!(32LU).VariantN.opAssign!(const(char[]) function(const(char[]) c)) error instantiating test.d(9): instantiated from here: __ctor!(const(char[]) function(const(char[]) c)) test.d(9): Error: template instance std.variant.VariantN!(32LU).VariantN.__ctor!(const(char[]) function(const(char[]) c)) error instantiating
Comment #1 by k.hara.pg — 2013-10-26T06:23:49Z
Comment #2 by github-bugzilla — 2013-10-26T13:32:16Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/4d30a5f278ec16b83148db85bc5bcaa2027f5644 Fix issue 11361 - Variant fails to compile with delegates containing const arguments. https://github.com/D-Programming-Language/phobos/commit/3fd3cee0d02cc0e114bfca3665512faabf93c4cb Merge pull request #1667 from Kapps/fix11361 Fix issue 11361 - Variant fails to compile with functions containing const arguments.
Comment #3 by github-bugzilla — 2013-10-26T13:34:59Z
Commit pushed to 2.064 at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/f2f11867dae630ba950090648ed7c9a3bda9471b Merge pull request #1667 from Kapps/fix11361 Fix issue 11361 - Variant fails to compile with functions containing const arguments.
Comment #4 by bugzilla — 2013-10-27T13:22:05Z
This fixes master, but fails to fix 2.064. Apparently there are other changes to phobos necessary. In fact, putting in the variant.d from master also fails its unittests in 2.064.
Comment #5 by bugzilla — 2013-10-27T13:26:34Z
This is not a regression for 2.064. In fact, pulling this fix breaks 2.064. I'll change the title.
Comment #6 by opantm2+dbugs — 2013-10-27T14:52:46Z
(In reply to comment #5) > This is not a regression for 2.064. In fact, pulling this fix breaks 2.064. > I'll change the title. Sorry, I wasn't aware that there was a difference between 2.064 beta and master, but I see now that there's a separate release branch for 2.064.