digitalmars.D.bugs - [Issue 14331] New: Can't call `destroy()` on a class with `alias
- via Digitalmars-d-bugs (39/39) Mar 24 2015 https://issues.dlang.org/show_bug.cgi?id=14331
https://issues.dlang.org/show_bug.cgi?id=14331 Issue ID: 14331 Summary: Can't call `destroy()` on a class with `alias this` on a struct field Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: initrd.gz gmail.com This code: class Test { struct Foo { int a, b, c; } Foo foo; alias foo this; } void main() { auto test = new Test(); destroy(test); } Fails to compile with the following message: $ rdmd test.d c:\D\dmd2\windows\bin\..\..\src\druntime\import\object.di(523): Error: cannot cast from Foo to void* test.d(13): Error: template instance object.destroy!(Test) error instantiating Failed: ["dmd", "-v", "-o-", "test.d", "-I."] Presumably because the `cast(void*)` is trying to cast the struct that is aliased instead of the class. Removing the `alias foo this` causes the code to compile. Using version 2.066.1 at the moment, but I didn't see anything related in the changelog for v2.067. --
Mar 24 2015