classes.union: Fix circular reference between multiple definitions. Fixes lol again.

Could be cleaner perhaps? I'm not seeing how right now.
db4
Doug Coleman 2013-03-23 14:57:09 -07:00
parent 8c19602ae9
commit 48638b9188
2 changed files with 16 additions and 1 deletions

View File

@ -136,3 +136,10 @@ PREDICATE: numba-ova-10 < union{ float integer }
! Issue #420 lol
[ "IN: issue-420 UNION: omg omg ;" eval( -- ) ]
[ error>> cannot-reference-self? ] must-fail-with
IN: issue-420
UNION: a ;
UNION: b a ;
[ "IN: issue-420 UNION: a b ;" eval( -- ) ]
[ error>> cannot-reference-self? ] must-fail-with

View File

@ -4,6 +4,7 @@ USING: accessors assocs classes classes.algebra
classes.algebra.private classes.builtin classes.private
combinators definitions kernel kernel.private math math.private
quotations sequences words ;
FROM: sets => set= ;
IN: classes.union
PREDICATE: union-class < class
@ -55,8 +56,15 @@ M: union-class update-class define-union-predicate ;
ERROR: cannot-reference-self class members ;
: union-members ( union -- members )
"members" word-prop [ f ] when-empty ;
: check-self-reference ( class members -- class members )
2dup member-eq? [ cannot-reference-self ] when ;
2dup [
dup dup [ union-members ] map concat sift append
2dup set= [ 2drop f ] [ nip ] if
] follow concat
member-eq? [ cannot-reference-self ] when ;
PRIVATE>