]> gitweb.factorcode.org Git - factor.git/commitdiff
bare: adding duplicate field check for structs
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jun 2022 17:07:45 +0000 (10:07 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jun 2022 17:07:45 +0000 (10:07 -0700)
extra/bare/bare-tests.factor
extra/bare/bare.factor

index 0a435338489efec4d37019806ae1b0a64cb5cda0..c19b542f1458284685a4acdc3d6ef70667b4cdb1 100644 (file)
@@ -403,3 +403,7 @@ type Person union {Customer | Employee | TerminatedEmployee}
 
 [ "type Thing union {int=0|int|str=0}" parse-schema ] [ duplicate-keys? ] must-fail-with
 [ "type Thing union {int=0|uint|str=0}" parse-schema ] [ duplicate-values? ] must-fail-with
+
+! struct checks
+
+[ "type Thing struct { a: int b: int a: int }" parse-schema ] [ duplicate-keys? ] must-fail-with
index 54871d16e637d66ae13a5997863d5255edf11de3..78ffabc477d0638c4e3a9bfb179efe0b204dff59 100644 (file)
@@ -233,7 +233,7 @@ struct-field-name = alpha+                => [[ >string ]]
 struct-field = struct-field-name ws ":"~ ws any-type => [[ >array ]]
 struct-fields = struct-field (ws struct-field)* => [[ first2 swap prefix ]]
 struct    = "struct"~ ws "{"~ ws~ struct-fields ws "}"~
-          => [[ struct boa ]]
+          => [[ check-duplicate-keys struct boa ]]
 
 union-members = union-member (ws "|"~ ws union-member)* => [[ first2 swap prefix ]]
 union-member  = any-type (ws "="~ ws number)? => [[ >array ]]