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

Restrict some boolean properties to Bool in the compiler #13614

Merged

Conversation

HertzDevil
Copy link
Contributor

Instead of using !! inside, the caller has to do this explicitly. (The compiler itself doesn't pass arguments that aren't already Bool.)

Note that the following is valid code, but infers Foo#@foo to be a Bool | Nil rather than Bool:

class Foo
  # no other declarations of `@foo` here

  def foo=(foo)
    @foo = !!foo
  end
end

This happened to Crystal::CodeError#@warning.

@straight-shoota straight-shoota added this to the 1.10.0 milestone Jul 1, 2023
@straight-shoota straight-shoota merged commit 2c9b552 into crystal-lang:master Jul 21, 2023
50 checks passed
@HertzDevil HertzDevil deleted the refactor/compiler-bool-ivars branch July 24, 2023 11:50
Blacksmoke16 pushed a commit to Blacksmoke16/crystal that referenced this pull request Dec 11, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants