www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [warning]reproducible error not downsizeable

reply Manfred Nowak <svv1999 hotmail.com> writes:
In a 3000 lines prog, I have something like this

<example>
class Class{
enum Type { CONST };
...
}
...

if( variable == Class.Type.CONST)
...
</example>

This worked until I introduced another `Type' in another class. Then 
the compiler complained that `CONST' is undefined in the `if'-
statement.

I worked around it by using `alias Type.CONST CONST;' and `if( variable 
== Class.CONST)'.

-manfred
Feb 05 2005
parent reply "Ben Hinkle" <ben.hinkle gmail.com> writes:
"Manfred Nowak" <svv1999 hotmail.com> wrote in message 
news:cu47qb$8ql$1 digitaldaemon.com...
 In a 3000 lines prog, I have something like this

 <example>
 class Class{
 enum Type { CONST };
 ...
 }
 ...

 if( variable == Class.Type.CONST)
 ...
 </example>

 This worked until I introduced another `Type' in another class. Then
 the compiler complained that `CONST' is undefined in the `if'-
 statement.

 I worked around it by using `alias Type.CONST CONST;' and `if( variable
 == Class.CONST)'.

 -manfred

What is the exact error? I can get "no property blah for type". I think the error message might be wierd, but here are some examples that cause the same error and some that don't. Since I can't tell from your post exactly what the code is or what the error is here are the snippets to play around with. this one errors: class A { enum E { V }; } enum E { V1 }; int main() { int y = A.E.V; return 0; } with test.d(6): no property 'V' for type 'int' test.d(6): cannot implicitly convert expression 1 of type int to E If I change line 6 to E y = A.E.V; it still errors (as it should). But when I change line 6 to A.E y = A.E.V; then it all works (as it should). In your code what is the type of "variable"?
Feb 06 2005
parent reply Manfred Nowak <svv1999 hotmail.com> writes:
"Ben Hinkle" wrote: 
[...]
 What is the exact error?

 test.d(6): no property 'V' for type 'int'

Yes that is the tpye of error message I got. However, the error is clarified to this code, whose exactly one error message I suppressed by defining the alias mentioned: <code> class Class{ enum Type{ CHAR, CCLASS, MARK}; struct Entry{ Type type; } Entry entry; void func(){ Class c= new Class; switch( c.entry.type){ case CHAR: case CCLASS: case Type.MARK: } } } void main(){} </code> which does not and should not compile, but _does_ compile when embedded in my 3000 lines program. -manfred
Feb 06 2005
parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Manfred Nowak schrieb am Sun, 6 Feb 2005 18:22:08 +0000 (UTC):
 "Ben Hinkle" wrote: 
 [...]
 What is the exact error?

 test.d(6): no property 'V' for type 'int'

Yes that is the tpye of error message I got. However, the error is clarified to this code, whose exactly one error message I suppressed by defining the alias mentioned: <code> class Class{ enum Type{ CHAR, CCLASS, MARK}; struct Entry{ Type type; } Entry entry; void func(){ Class c= new Class; switch( c.entry.type){ case CHAR: case CCLASS: case Type.MARK: } } } void main(){} </code> which does not and should not compile, but _does_ compile when embedded in my 3000 lines program.

Are you shure that "CHAR" and "CLASS" aren't defined in Class' parent scope? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCB2RM3w+/yD4P9tIRAuEDAJ4xSfhcP0LhSBwiUZo8oCd9Rq4X1wCcChzb UGOjIvpLMrJvgoX7etm+ytM= =c4jL -----END PGP SIGNATURE-----
Feb 07 2005
parent Manfred Nowak <svv1999 hotmail.com> writes:
Thomas Kuehne wrote: 

[...]
 Are you shure that "CHAR" and "CLASS" aren't defined in Class'
 parent scope?

No, i am not :). Thanks for this useful hint: there were declarations to circumvent the original error. Result: the error in the code, which I meanwhile changed is gone as mysteriously as it showed up. But the source in which the error showed up first is still present and it is of this form <code> class Class{ enum Type{ CHAR}; struct Entry{ Type type; } Entry entry; } //... void func(){ Class.Entry e; if( e.type == Class.Type.CHAR){}; } void main(){} </code> where `func' is the first function containing `CHAR' following the definition of the class and the error is | no property 'CHAR' for type 'int' and there are only two more errors of the same type for `CCLASS' and `MARK'. Because the code is heavily interwoven I do not see a chance to reduce it to fewer lines that show up this type of error only. And because the error shows up and goes mysteriously as the code changes, it is worth a warning only. -manfred
Feb 07 2005