solargraph
solargraph copied to clipboard
File.open(filename, &block) return type inferred incorrectly
This code:
# @return [Integer]
def foo
File.open('/dev/null') { |_| 1 }
end
puts foo # => 1
Typechecks incorrectly:
% solargraph typecheck --level typed test.rb
/path/to/test.rb:2 - Declared return type Integer does not match inferred type IO for #foo
1 problem found.
It seems to be unaware that when a block is supplied, the return value is that of the block.
Confirmed. I'm not sure how to handle this case yet, but I'll look into it.