diff --git a/json_serialization/lexer.nim b/json_serialization/lexer.nim index 3a79e69..ea63a2f 100644 --- a/json_serialization/lexer.nim +++ b/json_serialization/lexer.nim @@ -276,7 +276,7 @@ proc scanNumber(lexer: var JsonLexer) = lexer.tok = tkInt let scannedValue = lexer.scanInt() checkForNonPortableInt scannedValue - lexer.intVal = int(scannedValue) + lexer.intVal = int64(scannedValue) if lexer.stream[].eof: return c = lexer.stream[].peek() if c == '.': diff --git a/tests/test_lexer.nim b/tests/test_lexer.nim index f85c159..87ed2ae 100644 --- a/tests/test_lexer.nim +++ b/tests/test_lexer.nim @@ -40,6 +40,10 @@ suite "lexer tests": expectedToken tkInt, lexer.intVal == 190 expectedToken tkEof + lexerTest "int64 literal", "3568257348920230622": + expectedToken tkInt, lexer.intVal == 3568257348920230622'i64 + expectedToken tkEof + lexerTest "float literal", ".340": expectedToken tkFloat, lexer.floatVal =~ 0.340 expectedToken tkEof diff --git a/tests/utils.nim b/tests/utils.nim index d8d7307..565c2f9 100644 --- a/tests/utils.nim +++ b/tests/utils.nim @@ -3,7 +3,7 @@ import proc dedent*(s: string): string = var s = s.strip(leading = false) - var minIndent = 99999999999 + var minIndent = high(int) for l in s.splitLines: let indent = count(l, ' ') if indent == 0: continue