Bug 2359 – typeof(this) gives the wrong type in template mixins

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-09-14T06:10:00Z
Last change time
2014-03-01T00:37:00Z
Keywords
wrong-code
Assigned to
nobody
Creator
leo.dahlmann

Comments

Comment #0 by leo.dahlmann — 2008-09-14T06:10:15Z
Code: --------------- extern(C) int printf(char*, ...); class A { mixin Mix; } class B { mixin Mix; } template Mix() { void foo() { printf("%.*s\n", typeof(this).classinfo.name); } } void main() { (new A).foo(); (new B).foo(); } --------------- Output with any dmd since 1.032: main.A main.A This shows that typeof(this) in B.foo returns A. With dmd 1.031 the (imo correct) output is: main.A main.B
Comment #1 by h3r3tic — 2009-01-16T08:54:21Z
Appears to be fixed with DMD 1.039, probably related to http://d.puremagic.com/issues/show_bug.cgi?id=2527
Comment #2 by clugdbug — 2009-09-04T02:49:13Z
This works now. Clearly the same as bug 2527.