diff --git a/src/julia-parser.scm b/src/julia-parser.scm index ce1f6a67c8c43..36981c0ea0d50 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -342,7 +342,7 @@ ((<= l 32) (uint32 n)) ((<= l 64) (uint64 n)) ((<= l 128) `(macrocall @uint128_str ,s)) - (else `(macrocall @big_str ,s))))) + (else (error "Hex or binary literal too large for UInt128"))))) (define (sized-uint-oct-literal n s) (if (string.find s "o0") @@ -354,7 +354,7 @@ (else (uint64 n))) (if (oct-within-uint128? s) `(macrocall @uint128_str ,s) - `(macrocall @big_str ,s))))) + (error "Octal literal too large for UInt128"))))) (define (strip-leading-0s s) (define (loop i) diff --git a/test/numbers.jl b/test/numbers.jl index a3a07ec586b21..e187f0447d808 100644 --- a/test/numbers.jl +++ b/test/numbers.jl @@ -1652,7 +1652,8 @@ end @test isa(0b0000000000000000000000000000000000000000000000000000000000000000,UInt64) @test isa(0b00000000000000000000000000000000000000000000000000000000000000000,UInt128) @test isa(0b00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,UInt128) -@test isa(0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,BigInt) +#@test isa(0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,BigInt) +@test_throws ParseError parse("0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") @test isa(0b11111111,UInt8) @test isa(0b111111111,UInt16) @test isa(0b1111111111111111,UInt16) @@ -1662,7 +1663,8 @@ end @test isa(0b1111111111111111111111111111111111111111111111111111111111111111,UInt64) @test isa(0b11111111111111111111111111111111111111111111111111111111111111111,UInt128) @test isa(0b11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111,UInt128) -@test isa(0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111,BigInt) +#@test isa(0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111,BigInt) +@test_throws ParseError parse("0b111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") # octal literals @@ -1680,7 +1682,8 @@ end @test isa(0o000000000000000000000,UInt64) @test isa(0o0000000000000000000000,UInt128) @test isa(0o000000000000000000000000000000000000000000,UInt128) -@test isa(0o0000000000000000000000000000000000000000000,BigInt) +#@test isa(0o0000000000000000000000000000000000000000000,BigInt) +@test_throws ParseError parse("0o0000000000000000000000000000000000000000000") @test isa(0o11,UInt8) @test isa(0o111,UInt8) @test isa(0o11111,UInt16) @@ -1691,10 +1694,10 @@ end @test isa(0o1111111111111111111111,UInt64) @test isa(0o111111111111111111111111111111111111111111,UInt128) @test isa(0o1111111111111111111111111111111111111111111,UInt128) -@test isa(0o11111111111111111111111111111111111111111111,BigInt) -@test 0o4000000000000000000000000000000000000000000 == - 340282366920938463463374607431768211456 - +#@test isa(0o11111111111111111111111111111111111111111111,BigInt) +@test_throws ParseError parse("0o11111111111111111111111111111111111111111111") +#@test 0o4000000000000000000000000000000000000000000 == +# 340282366920938463463374607431768211456 # hexadecimal literals @test isa(0x00,UInt8) @@ -1706,7 +1709,8 @@ end @test isa(0x0000000000000000,UInt64) @test isa(0x00000000000000000,UInt128) @test isa(0x00000000000000000000000000000000,UInt128) -@test isa(0x000000000000000000000000000000000,BigInt) +#@test isa(0x000000000000000000000000000000000,BigInt) +@test_throws ParseError parse("0x000000000000000000000000000000000") @test isa(0x11,UInt8) @test isa(0x111,UInt16) @test isa(0x1111,UInt16) @@ -1716,7 +1720,8 @@ end @test isa(0x1111111111111111,UInt64) @test isa(0x11111111111111111,UInt128) @test isa(0x11111111111111111111111111111111,UInt128) -@test isa(0x111111111111111111111111111111111,BigInt) +#@test isa(0x111111111111111111111111111111111,BigInt) +@test_throws ParseError parse("0x111111111111111111111111111111111") # "-" is not part of unsigned literals @test -0x10 == -(0x10) @@ -1729,17 +1734,18 @@ end @test -0o0000000000000000000001 == -(0o0000000000000000000001) @test -0b00000000000000000000000000000000000000000000000000000000000000001 == -(0b00000000000000000000000000000000000000000000000000000000000000001) -@test -0x000000000000000000000000000000001 == -(0x000000000000000000000000000000001) -@test -0o0000000000000000000000000000000000000000001 == - -(0o0000000000000000000000000000000000000000001) -@test -0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 == - -(0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001) +#@test -0x000000000000000000000000000000001 == -(0x000000000000000000000000000000001) +#@test -0o0000000000000000000000000000000000000000001 == +# -(0o0000000000000000000000000000000000000000001) +#@test -0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 == +# -(0b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001) @test isa(-0x00,UInt8) @test isa(-0x0000000000000000,UInt64) @test isa(-0x00000000000000000,UInt128) @test isa(-0x00000000000000000000000000000000,UInt128) -@test isa(-0x000000000000000000000000000000000,BigInt) +#@test isa(-0x000000000000000000000000000000000,BigInt) +@test_throws ParseError parse("-0x000000000000000000000000000000000") # Float32 literals @test isa(1f0,Float32)