You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for the suggestion! You're definitely right that type annotations and other forms of contextual result types are an opportunity for optimization in the solver. I think we could effectively make the solver attempt overloads top-down if the solver knew that there was contextual information for a certain `+` in the chain and then attempt that disjunction first.
Additional Detail from JIRA
md5: c042299b2b7abee52cec4c90dadc37ed
Issue Description:
Following a suggestion on the Swift Forums.
Consider the following code snippet to get the operation tree of an expression:
With a couple more operations
the compiler starts failing to infer the type of every operand and throws the following error:
The only way to make the compiler's life easier is to explicitly write that the first integer literal is an Expression
and it won't raise errors even with a hundred of subsequent operations involved.
Could the explicit variable type annotation be used by the type checker to assign types in a top-down way instead of a bottom-up one?
Ideally, in an expression like
given the following variants for the + operator
I would constrain as
directly obtaining the only one valid type combination, instead of 18 different ones.
The text was updated successfully, but these errors were encountered: