Support versions of Raku where Any.Int does not die
An upcoming version of Raku will include a change that adds Int methods
to more invocants. This means that code like Any.Int
will no longer
throw an exception.
$ raku-new --version
Welcome to Rakudo™ v2022.12-1205-gfb205b31a.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.12-17-g60a268958.
$ raku-new -e 'dd try Any.Int'
Use of uninitialized value of type Any in numeric context
in code at -e line 1
0
but
$ raku-old --version
Welcome to Rakudo™ v2022.06.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.06.
$ raku-old -e 'dd try Any.Int'
Nil
When Game::Entities uses that value to check whether a given entity exists in a sparse set, the result is literally the opposite:
$ raku-new -e 'dd so try .[ 1; .[ 0; 1 ] ] with [ [], [], [] ]'
Use of uninitialized value of type Any in numeric context
in block at -e line 1
Bool::True
$ raku-old -e 'dd so try .[ 1; .[ 0; 1 ] ] with [ [], [], [] ]'
Bool::False
This commit changes the cases where we rely on this exception so that the code continues to work with versions of Raku that come before and after this release.
Edited by José Joaquín Atria