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
{{ message }}
Repository navigation
Function return-type with decomposition not inferred correctly #2968
changed the title [-]Decomposition seems to mix-up function return type[/-][+]Function return-type with decomposition not inferred correctly[/+]on Apr 30, 2015
We could either infer x's type as [Cat, Dog, Animal], or Animal[]. If we do the former, the next line of code is an error; if we do the latter, it's not.
It's arguable in the abstract which behavior is preferable (you can make convincing examples either way just by changing the names of the variables), but we shipped the Animal[] behavior and didn't want to have a breaking change.
Activity
[-]Decomposition seems to mix-up function return type[/-][+]Function return-type with decomposition not inferred correctly[/+]RyanCavanaugh commentedon Apr 30, 2015
We don't infer tuple types from array literals.
If you write code like this:
We could either infer
x's type as[Cat, Dog, Animal], orAnimal[]. If we do the former, the next line of code is an error; if we do the latter, it's not.It's arguable in the abstract which behavior is preferable (you can make convincing examples either way just by changing the names of the variables), but we shipped the
Animal[]behavior and didn't want to have a breaking change.