Skip to content

ASYNC116 does not flag integers above 2^64 - 1 #18762

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

If the sleep time is an integer above 2^64 - 1 (18446744073709551615) it will not be caught by ASYNC1116 playground

import trio


async def func():
    await trio.sleep(9999999999999999999) # ASYNC116

async def func():
    await trio.sleep(10000000000000000000000000000000000e100000000000000000000000000000000) # ASYNC116

async def func():
    await trio.sleep(99999999999999999999999999999999.0) # ASYNC116

async def func():
    await trio.sleep(18446744073709551615) # ASYNC116

async def func():
    await trio.sleep(18446744073709551616) # No error

async def func():
    await trio.sleep(99999999999999999999) # No error

I'm not an async user, but this may be worth fixing since my natural amount of 9s for a really big number is just above the limit this rule will detect.

I think the bug comes from here

Number::Int(int_value) => {
let Some(int_value) = int_value.as_u64() else {
return;
};
if int_value <= one_day_in_secs {
return;
}
}

If the as_u64 fails, that should mean the number is bigger than a u64, and thus the error should be reported, instead of skipped.

I think floats bypass this issue since they give inf if they are too big.

Version

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions