Invalid method called - reduced test case
Thomas Kuehne
thomas-dloop at kuehne.cn
Mon Mar 6 01:01:36 PST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tom S schrieb am 2006-03-03:
>
> DMD seems to be picky about the order of files passed to it. The
> attached program is a reduced version of what Ant encountered while
> working on Duit. I believe this is the same bug that Tyler reported
> regarding DWT.
> The .zip archive contains 3 D modules: a.d, b.d and main.d
>
> When compiled using:
> dmd b.d a.d main.d
>
> ...the resulting executable will be buggy. More specifically, an
> assertion (that I put in a function which should never be called) will
> fail :)
>
> The behavior is the same if one builds a .lib or .a file using
> dmd -c b.d a.d
>
> ...and then links to main.d
>
> Tested on Windows and Linux using the #D compiler farm ;)
Your test case seems to be broken:
=== a.d ===
private import b;
class Foo : Bar {
void foo() {
assert(false); // this should never be called !
}
}
=== b.d ===
class Bar {
private import a;
void bar() {
printf("Bar.bar()\n");
}
}
=== main.d ===
private import a;
void main() {
(new Foo()).bar();
}
You call Foo.bar in main - that's exactly the function you didn't expect
to execute.
The real bug is: the private of "private import a;" isn't enforced and thus
interpreted as "import a;" - the protection attributes are known not to
work properly in many situations.
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEDASk3w+/yD4P9tIRAljXAKDCRA+aN1NNiC4cgMyX8WNyXjYjkQCgwViR
rw5WgcU4IBE4e64MtO1zzUA=
=NlAj
-----END PGP SIGNATURE-----
More information about the Digitalmars-d-bugs
mailing list