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
The return lambda returns an Integer, but the type annotation declares that it should return a String, so Sorbet should report a type error statically.
I'm fine calling this bug closed after only solving the return type problem.
But note that checking argument types is trickier still:
In the CFG, Sorbet infers a type for the whole proc before it sees the Cast instruction which it could seemingly use to annotate the argument types when checking the body of the lambda.
Since it comes after, it picks T.untyped for the argument types when inferring a type for the the lambda.
The text was updated successfully, but these errors were encountered:
Sometimes it's useful to be able to use the arity of the block to guess
an overload.
This isn't perfect for all the reasons that overload checking isn't
perfect, but there are some places where this is useful, especially in
abstractions that check the proc's arity when deciding how to call the
block.
This is also a pre-requisite for doing something like #7741, which is a
partial fix for #3914 / #4149, where we infer the types of
`Kernel#lambda` blocks by codegenerating overloaded signatures.
Input
→ View on sorbet.run
Observed output
Expected behavior
The return lambda returns an
Integer
, but the type annotation declares that it should return aString
, so Sorbet should report a type error statically.I'm fine calling this bug closed after only solving the return type problem.
But note that checking argument types is trickier still:
→ View on sorbet.run
Observed output
In the CFG, Sorbet infers a type for the whole proc before it sees the
Cast
instruction which it could seemingly use to annotate the argument types when checking the body of the lambda.Since it comes after, it picks
T.untyped
for the argument types when inferring a type for the the lambda.The text was updated successfully, but these errors were encountered: