basex
basex copied to clipboard
Replace AtomType.ENUM and SeqType.values by EnumType
Besides type inspection (#2300), there is at least one more problem with the current representation of enum types: MapType.keyType, as a Type, can currently only hold AtomType.ENUM and misses the values. Thus the following currently returns true, in lack of any values to be checked, but should return false:
{'b' cast as enum('b'): 1} instance of map(enum('a'), item())
Also, a multi-value enum is defined as a union of single-value enums, but we currently use different representations for either: multi-value enums have multiple values in one SeqType instance, but a ChoiceItemType may spread them over several instances. This can cause instance tests to fail, e.g. with a wrong result of false in this case:
fn($a as (enum('a')|enum('b'))) as item()* {$a} instance of fn(enum('a', 'b')) as item()*
These changes
- remove
AtomType.ENUMandSeqType.values. - convert
EnumValuesinto an implementation ofTypecalledEnumType. - combine consecutive
EnumTypes before creating aChoiceItemType. This solves the above mentioned problem with the function instance test. - add parentheses around the result of
UnionTest.toString. This aligns the result withChoiceItemTypenotation and avoids misunderstanding when an occurrence indicator is appended later on. - add a few tests.