www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Associative array .length undefined symbol

reply Cal <callumenator gmail.com> writes:
Hi, I have a strange error with associative arrays. I have the following:

module mod_base;

abstract class Base
{
  int[string] m_arr;
}

module mod_derived;

class Derived : Base
{
   void foo()
   {
      m_arr["hello"] = 5;       /// This works fine
      auto len = m_arr.length;  /// Symbol error below
   }
}

I try to compile this and get:
|| Symbol Undefined _D6object28__T16AssociativeArrayTAyaTiZ16AssociativeArray6lengthMFNdZk|
||=== Build finished: 1 errors, 0 warnings ===|

But I can still set values in the array (it still behaves like an AA). If I
move the AA into the Derived class as a member, it works fine. The problem
seems to be that I
define Base in a separate module, which only contains this abstract class
definition. If I move the abstract class definition into the same module as the
Derived class,
all is fine.

I am just wondering why that might be?
Cheers,
Cal
Sep 07 2011
parent Cal <callumenator gmail.com> writes:
Actually this looks like Issue 5950, missed it the first time. Maybe thats why
it
happens.

Cal
Sep 07 2011