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
samwgoldman
changed the title
Rest parameters in poly types are not substituted ("Did not expect BoundT")
Tuple type-annotated rest parameters assertion failure ("Did not expect BoundT")
Aug 31, 2015
The above examples show my confusion between Array<T> and [T] types, the latter being a single element tuple type, which is an unsuitable annotation for rest parameters. However, the error message is unhelpful—PR attempts to address this.
Summary: Before this change, annotating a rest parameter with a tuple type could
lead to an ugly exception, "Did not expect BoundT"
Instead, warn the user when this pattern occurs, because a tuple type
does not represent rest parameters well. The tuple type implies a fixed
number of elements, but there can be any number of rest parameters, by
definition.
While debugging this, I also noticed an issue with bound type parameters
in another rest parameter use case: `fn<T>(...xs: T)`. Currently, this
also throws the ugly exception, but it's a bit tricker to resolve
because the error is thrown from the unification that occurs before the
type param can be substituted.
Fixesfacebook#762Closesfacebook#763
Reviewed By: @mroch
Differential Revision: D2402094
Pulled By: @jeffmo
Output:
The text was updated successfully, but these errors were encountered: