Skip to content

Harden union validation#29

Merged
johnstairs merged 6 commits intomainfrom
johnstairs/unique-union-types-with-aliases
Dec 8, 2022
Merged

Harden union validation#29
johnstairs merged 6 commits intomainfrom
johnstairs/unique-union-types-with-aliases

Conversation

@johnstairs
Copy link
Copy Markdown
Member

The cases in a union type are all required to be distinct. We were failing to catch cases where types were aliased and therefore the union should be invalid, e.g.:

MyInt: int
MyUnion: [int, MyInt]

Secondly, we were missing validation where the type arguments given to a union made up of generic type parameters results in an invalid union, e.g.:

MyGenericUnion<T,U>: [T, U]
MyUnion: MyGenericUnion<int, int>

We now surface an error at the location of the union, with locations where the type arguments are provided.

Screen Recording 2022-12-07 at 11 20 43 AM

We were also not catching a union made up of size and unit64 types, which are equivalent types.

Finally, we're changing the representation of the size type in C++ be yardl::Size, an alias of size_t if it is 64-bit, otherwise uint64_t.

Addresses #25

@johnstairs johnstairs merged commit 3cf7b50 into main Dec 8, 2022
@johnstairs johnstairs deleted the johnstairs/unique-union-types-with-aliases branch December 8, 2022 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants