slynch8 / 10x

10x IDE/Editor
190 stars 34 forks source link

namespaces conflated #2786

Open Muzza opened 2 months ago

Muzza commented 2 months ago

In my code, I have multiple projects with the same class names, but under different namespaces. The projects do NOT include each other at all. 10x is sometimes mixing up the namespaces, so if I do autocomplete on a member of ProjectA::MyClass, it will give me options from ProjectB::MyClass. But this only happens in combinations with the casting similar to issue #1502 I've tried for an hour to recreate this in a simple example, but failed. Maybe it is because in my own code, everything is split into Visual Studio libraries, I'm not sure, but I'm posting the code below anyway to see if it can give any hints.

file header3.h

namespace NS
{
    struct Application
    {
        static Application* Get( void );
        int app;
    };
};

file header.h

#include "header3.h"

namespace NS
{

namespace ProjectA
{
    struct Thing
    {
        int forProjectA;
    };

    struct ProjectAApp : public Application
    {
        void funcA();
        int a;
        Thing* thing = nullptr;
    };
    #define MYAPP ((ProjectAApp*)Application::Get())
};

};

file header2.h

#include "header3.h"

namespace NS
{

namespace ProjectB
{
    struct Thing
    {
        int forProjectB;
    };

    struct ProjectBApp : public Application
    {
        void funcB();
        int b;
        Thing* thing = nullptr;
    };
    #define MYAPP ((ProjectBApp*)Application::Get())
};

};

file main.cpp

#include "header2.h"    // only include ProjectB

namespace NS
{
namespace ProjectB
{

void MyFunc( void )
{
    MYAPP->thing->forProjectB;  // works ok in this example, but in my code it will autocomplete to forProjectA
}

};
};
Muzza commented 2 months ago

I've been able to create a full example now. There is a visual studio project in the attached zip file. ProjectB.cpp is where the problem is.

It comes down to this: Project A has a struct with namespaces NS::Thing Project B has a struct with namespaces NS::ProjectB::Thing

Project B does not include any files from Project A, and so does not know about NS::Thing But when Project B references NS::ProjectB::Thing, 10x gives autocomplete and syntax highlighting as though it is NS::Thing

10xVSTest1.zip