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

[bug]type checker report wrong infer type #264

Closed
SolaWing opened this issue Jan 19, 2020 · 3 comments
Closed

[bug]type checker report wrong infer type #264

SolaWing opened this issue Jan 19, 2020 · 3 comments

Comments

@SolaWing
Copy link
Contributor

SolaWing commented Jan 19, 2020

# frozen_string_literal: true

class A
  def initialize
    @a = 1
  end

  # @return [Boolean]
  def sss? # ERROR: report @return type `Boolean` does not match inferred type `Integer`
    b = @a == 1 # NOTE: b infer to Boolean
    @a == 1
  end
end

by the way, can we have a feature, only report the mismatch type, but ignore the uptyped warning? so I don't have to comment every simple code, just add what I need. sorbet typed: true is this behaviour

@SolaWing SolaWing changed the title type checker report wrong infer type [bug]type checker report wrong infer type Jan 19, 2020
@castwide
Copy link
Owner

The master branch has some updates that fix a bug in method type inference. I expect to release them in gem 0.38.3 tomorrow.

It makes sense to ignore missing @return tags when Solargraph can infer a return type on its own. I'll look into making it an option.

@castwide
Copy link
Owner

I posted a proposal for type checking levels in #192. The "normal" level would use your proposal of allowing untyped methods but validating the @return type if it exists.

@castwide
Copy link
Owner

Released in 0.38.3.

@castwide castwide closed this as completed Apr 6, 2020
jonnyboyC pushed a commit to jonnyboyC/solargraph that referenced this issue Apr 8, 2020
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