[Issue 9345] New: CTFE fails when using std.string.format with imported string enum

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 18 03:43:43 PST 2013


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

           Summary: CTFE fails when using std.string.format with imported
                    string enum
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: yazan.dabain at gmail.com


--- Comment #0 from yazan.dabain at gmail.com 2013-01-18 03:43:42 PST ---
File enumfile.d
---------------

module enumfile;

enum Foo : string {
  a = "Please print me",
}


File main.d
-----------

import enumfile;
import std.stdio; //without importing std.stdio or any other package, the CTFE
error disappears
import std.string;


void main() {
  pragma(msg, "%s".format(Foo.a));
}

Compiler output:
format.d(7): Error: cannot cast a read-only string literal to mutable in CTFE
format.d(7):        called from here: format("%s", "Please print me")
format("%s", "Please print me")

The code compiles correctly when either the import for the unrelated package is
commented out, or when the enum is moved to the same file.

-- 
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