On Thursday 15 May 2008 14:13:32 NotFound wrote:

> Parrot lacks loop avoidance in class hierarchy. This examples segfaults:
>
> .sub main
>   $P1 = newclass 'Foo'
>   addparent $P1, $P1
> .end
>
> .sub main
>   $P1 = newclass 'Foo'
>   $P2 = newclass 'Bar'
>   addparent $P1, $P2
>   addparent $P2, $P1
> .end
>
> The attached patch modifies add_parent in class, checking that the new
> parent is not self, and that none of his parents is.
>
> It checks the complete list of parents to work the same way even on
> override of isa. The intention is to avoid the fault in MRO, not to
> forbid experiments with inheritance.
>
> No tests yet, this patch is for evaluation and discussion.

Seems reasonable to me.  If you have tests, I'll apply it.

-- c

Reply via email to