pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Do not warn on bad return for infinite loops

Open grievejia opened this issue 9 months ago • 1 comments

Minimal repro:

def derp(x: int) -> bool: ...
def test(y: int) -> int:
    while True:
        if derp(y):
            return 42
        else:
            y += 1

Expected: No error Actual: Function declared to return int, but one or more paths are missing an explicit return [bad-return]

grievejia avatar Apr 16 '25 03:04 grievejia

Sandbox url: https://pyrefly.org/sandbox/?code=CYUwZgBKBOAOAUAPAXBAlgOwC4EoIFoA+CAIwHsyAbVAOjoChRIsQBnLeAT1U1wON7J6EERADuACzSUQEACrQAriCGi16SDASccq9fuggsi6BggAWAEzD9EEJVYqbt0ZwgBqALwQAjEA

lolpack avatar May 01 '25 02:05 lolpack

I think this is fixed?

lolpack avatar Jul 22 '25 14:07 lolpack

Sandbox still shows the same error to me.

grievejia avatar Jul 22 '25 16:07 grievejia

Looks like it is now fixed, I see no errors in sandbox

stroxler avatar Aug 25 '25 18:08 stroxler