-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversion is used on a sum type even if it is unnecessary #7854
Comments
This will bite us especially once we start adding I have a valid usecase, where I want to accept either a See my motivating example - what happens if we add a conversion from
yielding
As we can see, the call
|
Fixes #7854 by checking all elements of a union type for direct match and only then, if direct match isn't available, applying conversions.
Jaroslav Tulach reports a new STANDUP for yesterday (2023-10-04): Progress: - Avoid unnecessary conversions: #7952
Next Day: Bugfixing, websocket polyfill |
See the following example:
It currently yields:
It means that the first type of a sum type is treated specially. In
f2
, even though my value is already Text - so it already fits the expected type, it gets converted, because a conversion to the first type is found. We can see that when no conversion is found (f3 44
) it is passed unchanged okay.I don't think this is right. If the type already fits the requested sum type - why trigger a conversion?
The text was updated successfully, but these errors were encountered: