On 2/10/24 02:41, Elizabeth Mattijsen wrote:
On 10 Feb 2024, at 08:56, ToddAndMargo via perl6-users <perl6-us...@perl.org> 
wrote:

Hi All,

Is there a switch to tell Raku to bomb out with a
type mismatch rather than coercing the following?

my uint16 $x = -1
65535

No, this is intentional behaviour on native integers.

Rats.

I type cast my variable when I can to keep me out of trouble
("Expected Int but got Str").  Guess I got a bit too
lazy.   I am going to have to be more careful when
dealing with Cardinals (unit's).  I did get stung by this
yesterday. Took me hours to figure it out.

Note that you can increment such a value without problems:

[0] > my uint16 $x = -1;
65535
[1] > ++$x
0

Oh now that is really sneaky and speaks
of any underlying understand of bit wise
operations!  :-)

Thank you!


Reply via email to