steep icon indicating copy to clipboard operation
steep copied to clipboard

Raise UnsupportedSyntax if a proc object is given as block-pass-argument

Open tk0miya opened this issue 1 year ago • 1 comments

At present, users will see BlockTypeMismatch diagnostic when a proc object is passed as block-pass-argument. We'll usually see the diagnostic with &method idiom.

[1, 2, 3].map(&method(:puts))

But there is nothing to do from the user side because such a call is not invalid. It seems like a false positive.

This changes the diagnostic type for the case to UnsupportedSyntax. It notifies users that the source code is valid and that change is unnecessary.

refs: #149

tk0miya avatar Sep 30 '24 18:09 tk0miya

Now, https://github.com/soutaro/steep/pull/1276 has been merged into the master. But this is still needed, I believe. We still have the possibility of getting BlockTypeMismatch because #1276 only covers the case of &method(:name).

For example, the following code will cause the diagnostic:

meth = method(:puts)
[1, 2, 3].map(&meth)

block = proc { |n| n.to_s }
[1, 2, 3].map(&block)

tk0miya avatar Nov 26 '24 11:11 tk0miya