First pass of combining multiple union types #20014
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've worked with some much simpler compilers before, thought it was about time I made an attempt at something on a more serious scale.
I had an alternate attempt to address this via an extra case within TypeOps, but that seemed to have significantly more ripple effects than I was anticipating.
Avoided using a traditional set for comparisons such that I could maintain a guarantee of ordering based on the order at the inputs. The output order is deterministic for a given input type, but I have not aimed for consistency between conceptually similar types.
My understanding is that by limiting this to inferred types, it should only impact a type that is not user provided, so use cases where a user wants a non-impactful type can be maintained through compilation.
Would likely want to expand this to cover and types as well as or types in the same code.
I'm fully expecting to be ripped apart on performance, but the big win I had spotted was to make sure I was not using subset relations between OrTypes, as that appears to be expensive.
Expecting that there's still more to do here, but keen to get back into real code again, so any feedback would be very welcome