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