Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types are handled wrong when using namespaces #1126

Open
peckto opened this issue Mar 14, 2023 · 2 comments · May be fixed by #1581
Open

Types are handled wrong when using namespaces #1126

peckto opened this issue Mar 14, 2023 · 2 comments · May be fixed by #1581
Labels
bug Something isn't working cxx Related to C/C++ language parsing

Comments

@peckto
Copy link
Collaborator

peckto commented Mar 14, 2023

Unexpected behavior

When using namespaces, types are not associated with the correct namespace.
As a result, function calls are not resolved.

Code of interest

namespace ABC {
    namespace XYZ {
        struct A {
            A();
            void foo();
        };
    }
}

using namespace ABC::XYZ;
using namespace ABC;

int main() {
        ABC::XYZ::A a;
        XYZ::A b;
        A c;

        a.foo();
        b.foo();
        c.foo();

	return 0;
}

All three variables (a, b, c) should have the same type.
image

Similar behavior:

namespace ABC {
    namespace XYZ {
        struct A {
            void foo();
        };
    }
}


namespace ABC {
    namespace XYZ {
        void foo() {
            ABC::XYZ::A b;
            XYZ::A a;
            A c;

           a.foo();
           b.foo();
           c.foo();
        }
    }
}

Extensions to the library, e.g. added or changed LanguageFrontends or Passes

None

Changes to the configuration

None

@peckto peckto added bug Something isn't working cxx Related to C/C++ language parsing labels Mar 14, 2023
@oxisto
Copy link
Member

oxisto commented Apr 20, 2023

I am beginning to hate C++. Why the heck is XYZ::A inside the name space ABC::XYZ pointing to ABC::XYZ::A...

@oxisto
Copy link
Member

oxisto commented Apr 4, 2024

@peckto this might be solved with #1502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cxx Related to C/C++ language parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants