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
Generic functions which have a type parameter that is not used in an argument, but is used in a return type, should have their type argument inferred when an expected type is given.
For example, given a generic function
funfoo<T>() -> T { /* ... */ }
Then an invocation with an expected type should succeed, inferring the type parameter T to Bool:
letx: Bool = foo()
However, in an invocation without an expected type, the type argument cannot be inferred and an explicit type argument is necessary:
letx = foo<Bool>()
Suggested Solution
If an expected type is provided for an invocation, infer the type arguments based on the return type (if any).
The text was updated successfully, but these errors were encountered:
Issue to be solved
Generic functions which have a type parameter that is not used in an argument, but is used in a return type, should have their type argument inferred when an expected type is given.
For example, given a generic function
Then an invocation with an expected type should succeed, inferring the type parameter
T
toBool
:However, in an invocation without an expected type, the type argument cannot be inferred and an explicit type argument is necessary:
Suggested Solution
If an expected type is provided for an invocation, infer the type arguments based on the return type (if any).
The text was updated successfully, but these errors were encountered: