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

Boolean literal may have type of true or false #172

Merged
merged 2 commits into from
Jul 25, 2020
Merged

Boolean literal may have type of true or false #172

merged 2 commits into from
Jul 25, 2020

Conversation

soutaro
Copy link
Owner

@soutaro soutaro commented Jul 24, 2020

@tadd reported a case that returning false in a method with type of String | false got a type error while we are expecting no error for it.

# @type method read_string: () -> (String | false)
def read_string
  return false if has_value?
  some_value
end

This PR is to fix the issue by using hint to infer if the expected type of false literal is false (not bool).

soutaro added 2 commits July 25, 2020 00:58
* `true` <=> `TrueClass`
* `false` <=> `FalseClass`
* `nil` <=> `NilClass`
They may have type of `true` and `false`.
@soutaro soutaro merged commit 22d28ff into master Jul 25, 2020
@soutaro soutaro deleted the true-false branch July 25, 2020 13:04
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

Successfully merging this pull request may close these issues.

1 participant