[Issue 1723] New: __traits(getVirtualFunctions) on a non-function fails badly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Dec 10 08:45:30 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1723
Summary: __traits(getVirtualFunctions) on a non-function fails
badly
Product: D
Version: 2.008
Platform: PC
OS/Version: Linux
Status: NEW
Keywords: diagnostic, rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: dhasenan at gmail.com
---
class Foo {
int i;
void f() {}
}
void main () {
// Succeeds:
foreach (m; __traits(getVirtualFunctions, Foo, "f")) {}
// Fails:
foreach (m; __traits(getVirtualFunctions, Foo, "i")) {}
}
---
The error message is:
virtualfunctions_notfunction.d(9): Error: 'this' is only allowed in non-static
member functions, not main
virtualfunctions_notfunction.d(9): Error: this for i needs to be type Foo not
type int
I also get this when trying to access the .length property of the resulting
tuple.
If there are no virtual methods with the given name, an empty tuple should be
returned. At the very least, it should have a decent error message.
--
More information about the Digitalmars-d-bugs
mailing list