One thing that I noticed with enum types, which think is a compiler |
bug, is that if you use an enumeration value in two or more
enumerations, no compiler error is generated unless you refer to the
duplicated enum value.
Consider the following example.
No error will be generated unless you try to use Red as the value of
an enumerated type. Even then, the error message is not particularly
helpful: "Unknown Identifier 'red'". One might figure out what the
problem is if the two enum definitions are near each other. But if
they are separated (worse, in different modules), this message
wouldn't be very helpful at all.
I suspect that the compiler knows of (or ought to know of) the
enumeration conflict, at the latest after it has processed all of the
modules, and should indicate exactly what the problem is. For
example, "Duplicate enumeration value in types 'Animal', 'Color'".
Enum value compiler bug?
From: Don Kinzer <>|
> One thing that I noticed with enum types, which
> think is a compiler bug, is that if you use an
> enumeration value in two or more enumerations,
> no compiler error is generated unless you refer
> to the duplicated enum value.
> Consider the following example.
> Enum Color
> End Enum
> Enum Animal
> End Enum
> No error will be generated unless you try to use
> Red as the value of an enumerated type. Even then,
> the error message is not particularly helpful:
> "Unknown Identifier 'red'". [...]
I agree the error message needs work.
But it's OK in VB to have two or more enumeration constants with
the same name, as long as they belong to different types, and
since BasicX is modeled after VB, we also allow it.
The way VB resolves ambiguities is to require qualifiers. For
Dim C As Color
Dim A As Animal
C = Blue ' This is OK.
C = Color.Red ' Qualifier required.
A = Dog ' This is OK.
A = Animal.Red ' Qualifier required.
BasicX doesn't have this capability yet. What I usually do in
these circumstances is use a variation of Hungarian notation and
prefix enumeration constants with a three-letter prefix to make
each name unique.
I don't really like Hungarian notation, but I use it in cases
I do agree we need to improve the error message.
-- Frank Manning
-- NetMedia, Inc.