[ f ] [ 0 natural? ] unit-test
[ t ] [ 1 natural? ] unit-test
-[ "USE: math maybe: maybe: integer" eval( -- obj ) ] [ error>> bad-slot-value? ] must-fail-with
+[ t ] [ f maybe: maybe: integer instance? ] unit-test
+[ t ] [ 3 maybe: maybe: integer instance? ] unit-test
+[ f ] [ 3.03 maybe: maybe: integer instance? ] unit-test
INTERSECTION: only-f maybe: integer POSTPONE: f ;
effects kernel words ;
IN: classes.maybe
-TUPLE: maybe { class classoid initial: object read-only } ;
+! The class slot has to be a union of a word and a classoid
+! for TUPLE: foo { a maybe: foo } ; and maybe: union{ integer float } to work.
+! In the first case, foo is not yet a tuple-class when maybe: is reached,
+! thus it's not a classoid yet. union{ is a classoid, so the second case works.
+! words are not generally classoids, so classoid alone is insufficient.
+TUPLE: maybe { class union{ word classoid } initial: object read-only } ;
C: <maybe> maybe