Associative array .length undefined symbol

Cal callumenator at gmail.com
Wed Sep 7 22:14:26 PDT 2011


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


More information about the Digitalmars-d-learn mailing list