inheriting from itself would hang a tuple definition. only breaks if tuple is being redefined

db4
Doug Coleman 2009-09-01 04:02:44 -05:00
parent d893f3cdb7
commit d46d063f5f
2 changed files with 14 additions and 2 deletions

View File

@ -142,3 +142,8 @@ TUPLE: parsing-corner-case x ;
" x 3 }"
} "\n" join eval( -- tuple )
] [ error>> unexpected-eof? ] must-fail-with
TUPLE: bad-inheritance-tuple ;
[
"IN: classes.tuple.parser.tests TUPLE: bad-inheritance-tuple < bad-inheritance-tuple ;" eval( -- )
] [ error>> bad-inheritance? ] must-fail-with

View File

@ -56,11 +56,18 @@ ERROR: invalid-slot-name name ;
: parse-tuple-slots ( -- )
";" parse-tuple-slots-delim ;
ERROR: bad-inheritance class superclass ;
: check-self-inheritance ( class1 class2 -- class1 class2 )
2dup = [ bad-inheritance ] when ;
: parse-tuple-definition ( -- class superclass slots )
CREATE-CLASS
scan {
scan 2dup = [ ] when {
{ ";" [ tuple f ] }
{ "<" [ scan-word [ parse-tuple-slots ] { } make ] }
{ "<" [
scan-word check-self-inheritance [ parse-tuple-slots ] { } make
] }
[ tuple swap [ parse-slot-name [ parse-tuple-slots ] when ] { } make ]
} case
dup check-duplicate-slots