BaseXdb / basex

BaseX Main Repository.
http://basex.org
BSD 3-Clause "New" or "Revised" License
694 stars 265 forks source link

Replace AtomType.ENUM and SeqType.values by EnumType #2307

Closed GuntherRademacher closed 4 months ago

GuntherRademacher commented 5 months ago

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

ChristianGruen commented 4 months ago

Very nice; the new organisation of enums is much cleaner. Thanks.