[Issue 10056] New: Strange Error with templates and string.format

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 10 04:55:55 PDT 2013


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

           Summary: Strange Error with templates and string.format
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: puneet at coverify.org


--- Comment #0 from Puneet Goel <puneet at coverify.org> 2013-05-10 04:55:53 PDT ---
The following code compiles and runs well with version dmd-2.062.

Now I am compiling the following code with current github/master snapshot:
commit cfb631d40fe708fe04c54402fca8e0a72a2b850f
Merge: 526b57d aa70fab
Author: Martin Nowak <code at dawg.eu>
Date:   Fri May 10 01:34:12 2013 -0700

I get an error:
$ rdmd --force foo.d
...... /github-d/bin/../phobos/std/range.d(611): Error: static assert  "Cannot
put a dchar into a Appender!(string)"

I have tried minimizing this strange testcase, but could not go any further.
For example, if I comment out lines 2 to 4, dmd compiles the code without an
issue.


template Foo(T, U, string OP) {              // 1
  static if(T.ISEMPTY && U.ISEMPTY)          // 2
    enum bool S = false;                     // 3
  else                                       // 4
    enum bool S = false;
  alias Foo!(false, false, 0) Foo;
}

struct Foo(bool S, bool L, string VAL) {
  enum bool    ISEMPTY   = S;
}

template Foo(T) {
  alias Foo!(false, false, T.sizeof*8) Foo;
}

template Frop(size_t N) {
  alias Foo!(false, false, N) Frop;
}

struct Foo(bool S, bool L, size_t N) {
  import std.format;
  void bar(ref FormatSpec!char f) {}

  string bar() {
    import std.string;
    format("%b", 0);;
    return "";
  }

  public bool opEquals(T)(T other) {
    alias Foo!(typeof(this), T, "CMP") P;
    return false;
  }
}

void main() {
  alias Frop!1 Zoo;
  enum Zoo ZOO=Zoo.init;
}

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