Open connected-jlovelock opened 8 years ago
Just realized that you're explicitly checking for type = roAssociativeArray and not for whether it implements the ifAssociativeArray interface. That means it won't infinite loop for nodes, I guess, but also nodes don't work at all, and the problem still exists for AAs.
Since AAs are stored internally as pointers, they can contain references to themselves without requiring infinite memory. However, the current method of checking equality (check each k/v pair for equality, recursing if the value is also an AA) will enter an infinite loop.
Although this might sound like an awkward edge case, it's actually very common with the introduction of Scene Graph. All Scene Graph nodes implement ifArray (meaning they will be tested and prone to the same failure case as regular AAs). They also all have a focusedChild field, which -- while intended to be an internal field used for triggering observer callbacks only -- is freely readable, and nodes with focus have this field set to themselves.
Sample test cases:
Telnet output: