Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 1533: Enum value and class name conflict

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
.oisyn Posted - Sep 29 2006 : 10:24:59 AM
enum
{
    Foo,
    Bar,
    Baz
};

enum NamedEnum
{
    NamedFoo,
    NamedBar,
    NamedBaz
};

struct Foo
{
    int i;
};

struct NamedFoo
{
    int i;
};

int main()
{
    Foo f;
    NamedFoo nf;

    f.i = 3;   // #1
    nf.i = 4;  // #2
}


Albeit arguably bad practice, this is legal C++ code. The Foo and NamedFoo structures should hide the enum values with the same name. Surprisingly, VA X handles it differently depending on whether the enum type the value belongs to is named or not. On #1, after typing the '.', I get a suggestion list containing only the i, as I expect. But in #2, I get a list containing all other enum values belonging to NamedEnum, and no i.

The actual code I used to discover this bug was (in my opinion) not so bad practice. I was using a nested class:
struct MyStruct
{
    struct NamedFoo
    {
        int i;
    };

    void f(NamedFoo * f);
    {
        f->i = 3; // #3
    }

    void g(NamedFoo * f);
};

void MyStruct::g(MyStruct::NamedFoo * f)
{
    NamedFoo * f2 = f;
    f->i = 3;  // #4
    f2->i = 5; // #5
}


In #3 and #5, it shows the enum list as before. #4, however, is correct, so it seems that when you explicitely define the scope (MyStruct::NamedFoo instead of just NamedFoo) VA X actually understands that you're using the class type, and not the enum value.

I would like to suggest that listboxes always list the class elements instead of other enum values, as it is quite pointless to do a memberselection on an enum value.
4   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Oct 02 2006 : 4:38:36 PM
The VA context window showed c++ members using dot notation before C# ever existed.
Uniwares Posted - Oct 02 2006 : 3:03:11 PM
Well, i am referring to "problems" like showing members in the context list for C++ as namespace.class.member, which is simply wrong. Now we see similar in tooltips, VA View and who-knows-where-else (there's a thread about that some months back, still unresolved). All that literally started when VAX began to support C# big-style, which gives the impression that the WT LADS where trying to simplify C# integration by slightly modifying C++ parser/display.
feline Posted - Oct 02 2006 : 2:53:00 PM
.oisyn i am seeing the same thing. there are a couple of open bug reports for issues around duplicate class names. sometimes VA gets confused with duplicate names in the same file, even when they are at different scopes. this seems to be a variation on this theme, but different enough to get its own bug report.

case=2819

member selection on the enum value is certainly a bug, but member selection on an enum TYPE is quite useful, and something i did all the time in C++ in VS2003. as Uniwares says this is how it works in C#

it is ideal when a library class contains 8 or 10 different enum types, by using "class name :: enum type ::" you get a list of just the enum items you wish to choose between. unfortunately VS2005 does not like this, and wants the type to be removed *sigh* this is what the specification says, but it strikes me as being unhelpful.

Uniwares i don't think this actually has anything to do with mixing C++ and C#, but i do see what you are getting at. some of the problems with dot and :: in the displays go back a while. i think that at one point "float f = 3.2" was showing as "3::2" in tooltips, so it is possible that in fixing one display bug a new one was introduced.
Uniwares Posted - Sep 29 2006 : 7:37:04 PM
quote:
Originally posted by .oisyn

I would like to suggest that listboxes always list the class elements instead of other enum values, as it is quite pointless to do a memberselection on an enum value.



I might be pointless for C/C++ but not for C# - but for my taste VAX is now mixing too much C# and C++ together. Both in display of members for example (. instead of ::) and behavior like the one you've seen.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000