crystal
crystal copied to clipboard
Arrays have a 'silent' length limit due to Int32 type on size.
arr = Array(UInt8).new(2147483647,1u8)
arr << 2_u8
arr.size #=> -2147483648
This could be a very surprising behaviour to run across. Ideally an error should be raised or the limit removed entirely (hopefully).
A similar bug exists in Indexable, trying to use each_index also doesn't work if size is greater than 2**31-1 because the index variable (i
) defaults to the Int32 type. https://github.com/crystal-lang/crystal/blob/master/src/indexable.cr#L181
Version: Crystal 0.20.5+37 [2b57a98a9] (2017-02-08) OS: Arch Linux x86_64