fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Some numerical conversion don't check if the value fits into the target type

Open simonvonhackewitz opened this issue 1 year ago • 2 comments

This produces an error as expected

a i32 := 1234578
b i8 := a.as_i8
say "$a.as_i8 is $b"

but this doesn't

a i32 := 1234578
b u8 := a.as_u8
say "$a.as_u8 is $b" # should produce an error but doesn't

simonvonhackewitz avatar Jun 07 '24 08:06 simonvonhackewitz

for as_u8 this is caused by #3051

simonvonhackewitz avatar Jun 07 '24 10:06 simonvonhackewitz

but there are still some preconditions missing, e.g.

a i64 := 70000
b u16 := a.as_u16
say "$a.as_u16 is $b"

produces the output 70000.as_u16 is 4464

simonvonhackewitz avatar Jun 07 '24 10:06 simonvonhackewitz

this does not yet work

❯ fz -e 'a i32 := 1234578; b u8 := a.as_u8; say "$a.as_u8 is $b but should produce an error"'
1234578.as_u8 is 146 but should produce an error

simonvonhackewitz avatar Feb 05 '25 10:02 simonvonhackewitz

@simonvonhackewitz #3051 is fixed now. Please take a look at this issue again.

michaellilltokiwa avatar Feb 06 '25 10:02 michaellilltokiwa

solved in #4732

simonvonhackewitz avatar Feb 06 '25 11:02 simonvonhackewitz