classes.struct: raise an error in STRUCT: if there are duplicate slot names
parent
433f0d1ea6
commit
f2999ce778
|
@ -1,10 +1,10 @@
|
|||
! (c)Joe Groff bsd license
|
||||
USING: accessors alien alien.c-types alien.data alien.syntax ascii
|
||||
assocs byte-arrays classes.struct classes.tuple.private classes.tuple
|
||||
combinators compiler.tree.debugger compiler.units destructors
|
||||
io.encodings.utf8 io.pathnames io.streams.string kernel libc
|
||||
literals math mirrors namespaces prettyprint
|
||||
prettyprint.config see sequences specialized-arrays system
|
||||
assocs byte-arrays classes.struct classes.tuple.parser
|
||||
classes.tuple.private classes.tuple combinators compiler.tree.debugger
|
||||
compiler.units destructors io.encodings.utf8 io.pathnames
|
||||
io.streams.string kernel libc literals math mirrors namespaces
|
||||
prettyprint prettyprint.config see sequences specialized-arrays system
|
||||
tools.test parser lexer eval layouts generic.single classes ;
|
||||
FROM: math => float ;
|
||||
QUALIFIED-WITH: alien.c-types c
|
||||
|
@ -334,6 +334,14 @@ STRUCT: struct-that's-a-word { x int } ;
|
|||
"struct-class-test-1" parse-stream
|
||||
] [ error>> error>> unexpected-eof? ] must-fail-with
|
||||
|
||||
[
|
||||
"USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x uint } ;" eval( -- )
|
||||
] [ error>> duplicate-slot-names? ] must-fail-with
|
||||
|
||||
[
|
||||
"USING: alien.c-types classes.struct ; IN: classes.struct.tests STRUCT: struct-test-duplicate-slots { x uint } { x float } ;" eval( -- )
|
||||
] [ error>> duplicate-slot-names? ] must-fail-with
|
||||
|
||||
! S{ with non-struct type
|
||||
[
|
||||
"USE: classes.struct IN: classes.struct.tests TUPLE: not-a-struct ; S{ not-a-struct }"
|
||||
|
|
|
@ -363,7 +363,8 @@ PRIVATE>
|
|||
} case ;
|
||||
|
||||
: parse-struct-definition ( -- class slots )
|
||||
CREATE-CLASS 8 <vector> [ parse-struct-slots ] [ ] while >array ;
|
||||
CREATE-CLASS 8 <vector> [ parse-struct-slots ] [ ] while >array
|
||||
dup [ name>> ] map check-duplicate-slots ;
|
||||
PRIVATE>
|
||||
|
||||
SYNTAX: STRUCT:
|
||||
|
|
Loading…
Reference in New Issue