diff --git a/spec/compiler/lexer/lexer_spec.cr b/spec/compiler/lexer/lexer_spec.cr index 3bcbb1c5361767954d899241b0941efc5fa48ff8..cc23045224c24655e701cecb7db246d7b77fea5f 100755 --- a/spec/compiler/lexer/lexer_spec.cr +++ b/spec/compiler/lexer/lexer_spec.cr @@ -184,6 +184,7 @@ describe "Lexer" do it_lexes_i64 ["2147483648", "-2147483649", "-9223372036854775808"] it_lexes_u64 ["9223372036854775808", "-9223372036854775809"] + it_lexes_u64 ["18446744073709551615", "18446744073709551615", "14146167139683460000"] it_lexes_char "'a'", 'a' it_lexes_char "'\\b'", 8.chr diff --git a/src/compiler/crystal/syntax/lexer.cr b/src/compiler/crystal/syntax/lexer.cr index a94d8d81b6487f035a492496a3da63737ab596b4..7ac78b3d513bd4499e23bb8d772578d66da4af31 100644 --- a/src/compiler/crystal/syntax/lexer.cr +++ b/src/compiler/crystal/syntax/lexer.cr @@ -1138,8 +1138,11 @@ module Crystal if num_length == 20 i = 0 "18446744073709551615".each_byte do |byte| - if string_value.byte_at(i) > byte + string_byte = string_value.byte_at(i) + if string_byte > byte raise_value_doesnt_fit_in_uint64 string_value, start + elsif string_byte < byte + break end i += 1 end