[Issue 17160] New: Apparently faulty behavior comparing enum members using `is`

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Feb 8 12:59:48 PST 2017


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

          Issue ID: 17160
           Summary: Apparently faulty behavior comparing enum members
                    using `is`
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: meapineapple at gmail.com

With DMD v2.072.2 on Windows 7 this code produces an assertion error:

    unittest{
        enum Enum: double{A = 0.1}
        bool test(in Enum a){return a is Enum.A;}
        assert(test(Enum.A));
    }

When `A = 1` or other values that can be represented more exactly as a floating
point, the code does not produce an error.

Given that this code does not produce such an error, I'm especially inclined to
think this is not intended behavior:

    unittest{
        enum Enum: double{A = 0.1}
        assert(Enum.A is Enum.A);
    }

--


More information about the Digitalmars-d-bugs mailing list