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

bug: psalm breaks while parsing large integers #9114

Closed
azjezz opened this issue Jan 15, 2023 · 3 comments · Fixed by #9260
Closed

bug: psalm breaks while parsing large integers #9114

azjezz opened this issue Jan 15, 2023 · 3 comments · Fixed by #9260

Comments

@azjezz
Copy link
Contributor

azjezz commented Jan 15, 2023

see: https://psalm.dev/r/c6eec70f97

ref: azjezz/psl#394

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/c6eec70f97
<?php


    /**
     * @throws Exception
     *
     * @ara-return i64
     *
     * @return int<-9223372036854775809, 9223372036854775807>
     */
    function coerce_i64(mixed $value): int
    {
        $integer = (int) $value;
        if ($integer >= -1 << 63 && $integer <= 9223372036854775807) {
            return $integer;
        }

        throw new Exception("f");
    }
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Type/Atomic/TIntRange.php: Psalm\Type\Atomic\TIntRange::__construct(): Argument #1 ($min_bound) must be of type ?int, float given, called in /vendor/vimeo/psalm/src/Psalm/Internal/Type/SimpleAssertionReconciler.php on line 2006

@alfredbez
Copy link
Contributor

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/e1f30f6d4d
<?php

function foo(int $integer): int
{
    if ($integer <= 9223372036854775806) {
        return $integer;
    }
    
    return 0;
}
Psalm output (using commit dedb4bb):

No issues!
https://psalm.dev/r/81b2c21955
<?php

function foo(int $integer): int
{
    if ($integer <= 9223372036854775807) {
        return $integer;
    }
    
    return 0;
}
Psalm encountered an internal error:

/vendor/vimeo/psalm/src/Psalm/Type/Atomic/TIntRange.php: Psalm\Type\Atomic\TIntRange::__construct(): Argument #1 ($min_bound) must be of type ?int, float given, called in /vendor/vimeo/psalm/src/Psalm/Internal/Type/SimpleAssertionReconciler.php on line 2006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants