www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21960] New: Error in enum implicit conversion to string

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

          Issue ID: 21960
           Summary: Error in enum implicit conversion to string reports
                    wrong line number.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: rmaicle gmail.com

The following code produces the error: "cannot implicitly convert expression
`E.One` of type `E` to `string`" but reports the error to be in line 2. The
error is in line 5 where E.One is being assigned to Test.

~~~~~
import std.stdio;
enum E { One, Two }
void main() {
    enum R: string {
        Test = E.One
    }
    writeln(R.Test);
}
~~~~~

--
May 23