pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Check for `__bool__` for if/while conditions

Open grievejia opened this issue 8 months ago • 1 comments

Describe the Bug

Minimal repro:

class NotBoolable:
    __bool__: int = 3

if NotBoolable():
    pass

Actual: no error Expected: NotBoolable() is not convertible to bool

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAEByD2AXAQve4BGICmAuAUNEdAPokZohm7QCWAdotALzQDM++tAZnEqujBZsACgCUBYtAAOkCEA

(Only applicable for extension issues) IDE Information

No response

grievejia avatar May 17 '25 22:05 grievejia

@martindemello is working on this.

ndmitchell avatar May 19 '25 19:05 ndmitchell

fixed by 8ec4bca

martindemello avatar May 22 '25 20:05 martindemello