[Issue 14331] New: Can't call `destroy()` on a class with `alias this` on a struct field
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Mar 24 18:56:10 PDT 2015
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 at puremagic.com
Reporter: initrd.gz at 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.
--
More information about the Digitalmars-d-bugs
mailing list