Monday 18 October 2010

Error #1069 using namespaced members

Error:
ReferenceError: Error #1069: Property myNamespacedProperty not found on a.b.c.MyClass and there is no default value.
Seen when attempting to access a member (property/method/accessor) of a class that uses a custom namespace, e.g:
messaging_internals function getMillisecondsSinceSent():uint {
    return getTimer() - _lastSentTime;
  }
Obviously here "messaging_internals" is the namespace.

Answer:
Check that both declaration and use are using exactly the same definition of the namespace.  For example, check that you don't have a duplicate definition!

We saw this problem when project A had namespace An on methods in class Ac.  Used by project B in class Bc.  All looked fine, compiled fine but unit testing saw Error #1069.  Eventually realised that a bad refactoring had left a second copy of the namespace An in project B (where it had orignally been), leaving An obscured by the identically named Bn.  Bc was using Bn which failed to resolve to An hence members in Ac were unreachable!
 (Yes, I can add a diagram if anyone wants.)

Obviously ideally the tooling should highlight this.
HTH!

No comments:

Post a Comment