www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9681] New: std.variant.Algebraic with const members

http://d.puremagic.com/issues/show_bug.cgi?id=9681

           Summary: std.variant.Algebraic with const members
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-03-10 07:13:30 PDT ---
This code compiles with dmd 2.063alpha:


import std.variant: Algebraic;
struct A {}
alias Foo = Algebraic!(A);
void main() {
    const A bar;
    auto spam = Foo(bar); // line 6.
    assert(spam.peek!(const A)); // No assertion failure
    assert(spam.peek!A); // Assertion failure
}



And at runtime it asserts at line 8:

core.exception.AssertError test2(8): Assertion failure

I think that maybe line 6 should be refused, otherwise it becomes hard to catch
all possible things that can be inside "spam". In this program bar is like an
Algebraic!(A, const A).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 10 2013