Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typechecking doesn't allow for raise without arguments #418

Closed
wagenet opened this issue Feb 26, 2021 · 4 comments
Closed

Typechecking doesn't allow for raise without arguments #418

wagenet opened this issue Feb 26, 2021 · 4 comments

Comments

@wagenet
Copy link

wagenet commented Feb 26, 2021

begin
  raise StandardError, "error"
rescue
  puts "log something"
  raise # Reports: `Not enough arguments to Kernel#raise`
end

https://rubydoc.info/stdlib/core/Kernel:raise

@castwide
Copy link
Owner

I haven't been able to reproduce this problem. Kernel#raise is always seen as valid without arguments.

What versions of Solargraph and Ruby are you using?

@wagenet
Copy link
Author

wagenet commented Mar 1, 2021

Ruby 2.7.2
Solargraph 0.40.3
Running solargraph typecheck

Here's some actual code that I'm seeing the issue with. The later two raise both cause the Not enough arguments to Kernel#raise notice.

  module Retries
    def with_retry(times: 1, error: StandardError)
      raise ArgumentError, "must retry at least one time" if times < 1

      begin
        yield
      rescue Exception => e
        raise unless Array(error).any? { |match_error| match_error === e }
        raise if times == 0

        times -= 1
        retry
      end
    end
  end

@castwide
Copy link
Owner

This appears to be a problem specifically with core documentation for Ruby 2.7+. The definition was previously Kernel#raise(*), but now the definition is Kernel#raise(*, _). The latter is incorrect.

As a temporary stopgap, I'll probably add a redefinition of Kernel#raise to the core fills.

@castwide
Copy link
Owner

Fixed in v0.43.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants