[Issue 5048] New: string enum type not recognized as a string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 12 21:31:33 PDT 2010


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

           Summary: string enum type not recognized as a string
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: jmdavisProg at gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisProg at gmx.com> 2010-10-12 21:31:00 PDT ---
This program:

import std.stdio;

enum Val : string { a = "a", b = "b" }

void func(Val v1, Val v2)(int num)
{
    writeln("%s + %s -> %s", v1, v2, num);
}

void main()
{
}


fails to compile with this error:

prog.d(5): Error: arithmetic/string type expected for value-parameter, not Val
prog.d(5): Error: arithmetic/string type expected for value-parameter, not Val


However, you change Val to string in func's template parameters, then it does
compile. For some reason the compiler is not recognizing Val to be a string
type in func's template parameters. If I make Val an int, it works just fine
(well, make it an int and change the values of a and b to integers), so it
appears to be something to do with strings specifically.

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


More information about the Digitalmars-d-bugs mailing list