Open Frityet opened 2 months ago
Teal in general is pretty lax with bivariant function matching, so if we're going with bivariance for functions everywhere, then yes, ideally this should be accepted. (With the caveat of course that bivariant function matching is unsound by design — but a lot simpler to use in general...)
After all, this currently works without complaints:
local type FnType = function(...: any)
local f: FnType
f = function(name: string, age: integer)
end
...and this is a little trickier because generally we've been stricter about redeclarations of record functions. Which is, in general a good thing, because a function implementation not matching its forward-declarations done inside the record
is usually a sign of a mistake somewhere.
However, here the "redeclaration" is implicit, because the function field was originally declared in an interface, and it is more likely that non-identical function types are used, as in your example. Gonna think a bit more about this!
That's good feedback, keep it coming!
Motivating example:
Currently this fails because