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.ENUM and SeqType.values.
convert EnumValues into an implementation of Type called EnumType.
combine consecutive EnumTypes before creating a ChoiceItemType. This solves the above mentioned problem with the function instance test.
add parentheses around the result of UnionTest.toString. This aligns the result with ChoiceItemType notation and avoids misunderstanding when an occurrence indicator is appended later on.
Besides type inspection (#2300), there is at least one more problem with the current representation of
enum
types:MapType.keyType
, as aType
, can currently only holdAtomType.ENUM
and misses the values. Thus the following currently returnstrue
, in lack of any values to be checked, but should returnfalse
:Also, a multi-value
enum
is defined as a union of single-valueenum
s, but we currently use different representations for either: multi-valueenum
s have multiple values in oneSeqType
instance, but aChoiceItemType
may spread them over several instances. This can cause instance tests to fail, e.g. with a wrong result offalse
in this case:These changes
AtomType.ENUM
andSeqType.values
.EnumValues
into an implementation ofType
calledEnumType
.EnumType
s before creating aChoiceItemType
. This solves the above mentioned problem with the function instance test.UnionTest.toString
. This aligns the result withChoiceItemType
notation and avoids misunderstanding when an occurrence indicator is appended later on.