[Issue 2740] New: Template Mixins do not work as advertised

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 17 19:13:31 PDT 2009


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

           Summary: Template Mixins do not work as advertised
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: andrew.livesay at gmail.com


// As I understand TFM, all three calls to go() should be printing 'false'.

import std.stdio;

interface IFooable {
  bool foo();
}

template TFoo() {
  bool foo() { return true; }  
}

class Foo : IFooable {
  mixin TFoo;
  bool foo() { return false; }
}

class _Foo : IFooable {
  mixin TFoo;
}

class Foo2 : _Foo {
  bool foo() { return false; }
}

class Foo3 : IFooable {
  bool foo() { return false; }
}

void go(IFooable p) {
  writefln(p.foo);
}

void main() {
  Foo p = new Foo();
  Foo2 p2 = new Foo2();
  Foo3 p3 = new Foo3();
  go(p); // output is "true" <------- Why isn't this false?
  go(p2); // output is "false"
  go(p3); // output is "false"
}


-- 



More information about the Digitalmars-d-bugs mailing list