View mode: basic / threaded / horizontal-split · Log in · Help
January 18, 2013
[Issue 9345] New: CTFE fails when using std.string.format with imported string enum
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@puremagic.com
       ReportedBy: yazan.dabain@gmail.com


--- Comment #0 from yazan.dabain@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: -------
January 19, 2013
[Issue 9345] CTFE fails when using std.string.format with imported string enum
http://d.puremagic.com/issues/show_bug.cgi?id=9345



--- Comment #1 from yazan.dabain@gmail.com 2013-01-19 07:02:18 PST ---
I was looking into this again today. This problem only exists when using rdmd.
Compiling using DMD v2.061 or HEAD is successful.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 19, 2013
[Issue 9345] CTFE fails when using std.string.format with imported string enum
http://d.puremagic.com/issues/show_bug.cgi?id=9345



--- Comment #2 from yazan.dabain@gmail.com 2013-01-19 07:10:10 PST ---
Okay, it is the include flag.
dmd -I. main.d
Fails with the same output as above.

BTW, the compiler output shows correctly the filename main.d and not format.d
as in the first comment. I was testing locally using a file named format.d.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 29, 2013
[Issue 9345] CTFE fails when using std.string.format with imported string enum
http://d.puremagic.com/issues/show_bug.cgi?id=9345


yazan.dabain@gmail.com changed:

          What    |Removed                     |Added
----------------------------------------------------------------------------
            Status|NEW                         |RESOLVED
        Resolution|                            |FIXED


--- Comment #3 from yazan.dabain@gmail.com 2013-03-29 00:57:19 PDT ---
Fixed on git HEAD by https://github.com/D-Programming-Language/dmd/pull/1804

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Top | Discussion index | About this forum | D home