Jump to content
  • Advertisement
y18a

Namespaces can not be resolved well in some cases

Recommended Posts

namespace A
{
    class X
    {
      X() { print("X()"); }
    }
}

void X()
{
  auto test = A::X();
}

void main()
{
  X();
}

When preparing and executing the above, we output the following.

>asrun.exe script2.as
script2.as (10, 1) : INFO : Compiling void X()
script2.as (12, 8) : ERR  : Data type can't be 'void'
script2.as (0, 0) : ERR  : Script failed to build

 

auto test = A::X();

The reason for doing this is because it really is `class@ X`. Also, if executed from another namespace as follows, it will be executed normally.

namespace A
{
    class X
    {
      X() { print("X()"); }
    }
}

namespace B
{
  void X()
  {
    auto test = A::X();
  }
}

 

Share this post


Link to post
Share on other sites
Advertisement

I've identified the root cause for this problem. Unfortunately the fix is not trivial, as I'll need to redesign how symbol names are looked up within namespaces. 

I'll fix it, but it will probably take a while.

Share this post


Link to post
Share on other sites
Posted (edited)
namespace X {
  class A {
    void test() {
    }
  };
  class B : A {
    void test() {
      A::test();
    }
  };
}

Thank you for fixing it.
However, after this fix, the above code now causes a compile error.

script2.as (8, 7) : ERR  : No matching symbol 'A::test'

`X::A::test ()` will compile successfully.

Edited by y18a

Share this post


Link to post
Share on other sites

Which revision of AngelScript did you try? I cannot reproduce the problem in revision 2523, which was checked in on Aug 1st. 

 

Share this post


Link to post
Share on other sites

I am sorry, the code I presented was wrong.

If it is the following code it will result in an error.

 

namespace X {
  class A {
    void test() {
    }
  };
}
namespace Y {
  class B : X::A {
    void test() {
      A::test();
    }
  };
}

Previously, this was also successfully compiled.

Share this post


Link to post
Share on other sites

Thanks for fixing it.
Another problem is that if you run the following code in a debug build, it stops with an exception.

namespace X {
  class A {
    void test()
      {
      }
  };
}

X::A A;
/*
It is the same also as follows.

X::A __a;
X::A@ get_A()
{
  return __a;
}
*/

namespace X {
  class Test {
    void test()
      {
        A.test();
      }
  }
}
Assertion failed: false, file sdk\angelscript\source\as_compiler.cpp, line 9789

Previously, this was able to call `A::test ()`.
Also, if you indicate `::A.test()` in the global scope, you can compile normally.

 

Edited by y18a

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!