[Issue 2740] Template Mixins do not work as advertised

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 8 10:40:41 PDT 2010


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


David Simcha <dsimcha at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dsimcha at yahoo.com
           Severity|normal                      |critical


--- Comment #2 from David Simcha <dsimcha at yahoo.com> 2010-09-08 10:40:17 PDT ---
This seems to happen iff the class is called from its interface handle:

import std.stdio;

interface IFooable {
  bool foo();
}

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

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

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

void main() {
  Foo p = new Foo();
  go(p);            // true
  writeln(p.foo);   // false
  IFooable i = p;
  writeln(i.foo);   // true
}

Marking as critical because this is an extremely subtle wrong-code bug that can
lead to some pretty frustrating debugging.

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