]> gitweb.factorcode.org Git - factor.git/commitdiff
bare: check duplicates for unions too
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jun 2022 16:45:10 +0000 (09:45 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 16 Jun 2022 16:45:10 +0000 (09:45 -0700)
extra/bare/bare-tests.factor
extra/bare/bare.factor

index da8f0382a142ab946956fd38ff1b500cfe0c73fd..0a435338489efec4d37019806ae1b0a64cb5cda0 100644 (file)
@@ -398,3 +398,8 @@ type Person union {Customer | Employee | TerminatedEmployee}
       E = 99
     }" parse-schema
 ] [ duplicate-values? ] must-fail-with
+
+! union checks
+
+[ "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
index e22a6e5e94cbb6a092b422bba2d9e228a42cd33e..54871d16e637d66ae13a5997863d5255edf11de3 100644 (file)
@@ -238,7 +238,7 @@ struct    = "struct"~ ws "{"~ ws~ struct-fields ws "}"~
 union-members = union-member (ws "|"~ ws union-member)* => [[ first2 swap prefix ]]
 union-member  = any-type (ws "="~ ws number)? => [[ >array ]]
 union     = "union"~ ws "{"~ ws ("|"?)~ ws union-members ws ("|"?)~ ws "}"~
-          => [[ assign-values union boa ]]
+          => [[ assign-values check-duplicates union boa ]]
 
 aggregate = optional|list|map|struct|union