www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Unable to understand this compiler error

reply Lubos Pintes <lubos.pintes gmail.com> writes:
Hi,
I discovered this while playing with DGUI's treeview module. Here is a 
program that generates exactly the same error that looks weird to me:
module a;
import std.stdio;

alias void* pvoid;

enum E : pvoid {
   a=cast(pvoid)-1,
   b=cast(pvoid)-2,
}

void foo(E e=E.a) {
   writeln("Hello from foo");
}

void main() {
   foo();
}

a.d(11): Error: no property 'a' for type 'void'

I see no "void" there, except that foo has a return type of void.
Oct 10 2012
next sibling parent "Jesse Phillips" <jessekphillips+D gmail.com> writes:
On Wednesday, 10 October 2012 at 14:52:00 UTC, Lubos Pintes wrote:
 Hi,
 I discovered this while playing with DGUI's treeview module. 
 Here is a program that generates exactly the same error that 
 looks weird to me:
 module a;
 import std.stdio;

 alias void* pvoid;

 enum E : pvoid {
   a=cast(pvoid)-1,
   b=cast(pvoid)-2,
 }

 void foo(E e=E.a) {
   writeln("Hello from foo");
 }

 void main() {
   foo();
 }

 a.d(11): Error: no property 'a' for type 'void'

 I see no "void" there, except that foo has a return type of 
 void.
I'm guessing a compiler bug. Looks to me as though it is confusing E to be of type void (you declared it to be enumeration of void*)
Oct 10 2012
prev sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Lubos Pintes:

 I see no "void" there, except that foo has a return type of 
 void.
Minimized: enum Foo : void* { a = null } void main() { auto f = Foo.a; } enums are good for ints, ubytes, longs, chars, etc. The more types you try to put in them, the more compiler holes you will find. Bye, bearophile
Oct 10 2012
parent reply Lubos Pintes <lubos.pintes gmail.com> writes:
Interesting. In treeview module I mentioned, there is an enum containing 
some numeric values cast from HTREEITEM, which is in fact HANDLE, which 
is void* if I understand properly.
I tried to convert DGUI to use dsource' WindowsAPI project, and at least 
from compiler perspective, everything worked except this TreeView 
weirdness...

Dňa 10. 10. 2012 17:51 bearophile  wrote / napísal(a):
 Lubos Pintes:

 I see no "void" there, except that foo has a return type of void.
Minimized: enum Foo : void* { a = null } void main() { auto f = Foo.a; } enums are good for ints, ubytes, longs, chars, etc. The more types you try to put in them, the more compiler holes you will find. Bye, bearophile
Oct 10 2012
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Lubos Pintes:

 Interesting. In treeview module I mentioned, there is an enum 
 containing some numeric values cast from HTREEITEM, which is in 
 fact HANDLE, which is void* if I understand properly.
 I tried to convert DGUI to use dsource' WindowsAPI project, and 
 at least from compiler perspective, everything worked except 
 this TreeView weirdness...
Anyway, this seems a compiler bug, so probably it should be added to bugzilla. Bye, bearophile
Oct 10 2012
parent "bearophile" <bearophileHUGS lycos.com> writes:
 Anyway, this seems a compiler bug, so probably it should be 
 added to bugzilla.
http://d.puremagic.com/issues/show_bug.cgi?id=8802
Oct 11 2012