Closed dgriffie79 closed 13 hours ago
Actually I think it is something wrong with the f32 array operators, here's an example where it works with i32 but not f32
use core {*}
foo :: (a: [2]f32) -> void {
printf("{} {}\n", a, a + a)
}
f2 :: () -> [2]f32 {
return .[1, 2]
}
ioo :: (a: [2]i32) -> void {
printf("{} {}\n", a, a + a)
}
i2 :: () -> [2]i32 {
return .[1, 2]
}
main :: () {
foo(f2())
ioo(i2())
}
[ 1.0000, 2.0000 ] [ 0.0000, 4.0000 ]
[ 1, 2 ] [ 2, 4 ]
This has been addressed in the latest version of Onyx by making fixed-sized arrays ([N] T
) pass-by-value instead of pass-by-pointer. They are now copied as arguments and return values, which fixed the weird aliasing issues you were running into.
This was fixed awhile ago, but I am finally getting around to cleaning up the issue list. Thanks for the bug report!
Expected output:
Actual ouput: