Crystal: Big UInt128 literals don't work

Created on 17 Feb 2019  路  4Comments  路  Source: crystal-lang/crystal

1_329_227_995_784_915_872_903_807_060_280_344_576_u128

https://carc.in/#/r/6a2o

Invalid UInt64: 1329227995784915872903807060280344576 (ArgumentError)
from ???
from ???
from ???
from ???
from ???
from ???
from ???
from ???
from __crystal_main
from main
from __libc_start_main
from _start
from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

But, I can get the same UInt128 from Slice(UInt8):

source = Bytes[1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8]
pp source.reduce(0u128) { |r, v| (r << 8) | v } # => 1329227995784915872903807060280344576_u128

https://carc.in/#/r/6a6i

bug compiler

Most helpful comment

Yes, this is a known issue. See #5818 and #7015. Apparently those were closed without a good reason (it was never fixed and the PR that supposed to fix it is wrong (or at least not efficient as I'd like it to).

Let's keep this open to represent this issue.

All 4 comments

Yes, this is a known issue. See #5818 and #7015. Apparently those were closed without a good reason (it was never fixed and the PR that supposed to fix it is wrong (or at least not efficient as I'd like it to).

Let's keep this open to represent this issue.

There's #7093, as I understand waiting for the final touches. Would be great if it made it into 0.28.0 release.

@Sija No new commits for about two months.

@delef True, but that's the most complete PR to date.

Was this page helpful?
0 / 5 - 0 ratings