[Issue 8486] Possibly wrong interaction of Variant and const arrays

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 18 19:51:14 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=8486

--- Comment #8 from berni44 <bugzilla at d-ecke.de> ---
(In reply to David Nadlinger from comment #7)
> Removal of "head const", i.e. the outer layer, is intentional.
OK. In that case this is a Phobos bug. The solution would be to make peek
remove "head const" on the given type und check if that's the type of the
Variant. I've got too few experience on const, so I cannot fix this. I tried to
add a small template which returns what it get's (just out of curiosity, if
that could work). With this, peek could compare the type of the returned value
to the value of the Variant. But this did not work out well. Partly, because
the template needs to be given a value and not a type, partly because of inout
gets in the way.

I don't know if it's of much use, because this can be easily derived from the
post above, but I created this unittest which currently does not pass but a
corrected version of peek should pass:

unittest
{
    const int[] arr;
    Variant a = Variant(arr);
    assert(a.peek!(typeof(arr)) !is null);
}

--


More information about the Digitalmars-d-bugs mailing list