Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions JuliaSyntax/src/julia/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,14 @@ function lex_digit(l::Lexer, kind)
if !accept_number(l, isdigit) || !had_digits
return emit(l, K"ErrorInvalidNumericConstant") # `0x1p` `0x.p0`
end
# Check for invalid trailing decimal point
# https://github.com/JuliaLang/julia/issues/60189
pc = peekchar(l)
if pc == '.'
accept_batch(l, c->(c == '.' || isdigit(c)))
# `0x1p3.` `0x1p3.2` `0x1.5p2.3`
return emit(l, K"ErrorInvalidNumericConstant")
end
elseif isfloat
return emit(l, K"ErrorHexFloatMustContainP") # `0x.` `0x1.0`
end
Expand Down
4 changes: 4 additions & 0 deletions JuliaSyntax/test/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ end
@test onlytok("0x.p0") == K"ErrorInvalidNumericConstant"
@test onlytok("0x.") == K"ErrorHexFloatMustContainP"
@test onlytok("0x1.0") == K"ErrorHexFloatMustContainP"
# https://github.com/JuliaLang/julia/issues/60189
@test onlytok("0x1p3.") == K"ErrorInvalidNumericConstant"
@test onlytok("0x1p3.2") == K"ErrorInvalidNumericConstant"
@test onlytok("0x1.5p2.3") == K"ErrorInvalidNumericConstant"
end

@testset "binary literals" begin
Expand Down
3 changes: 3 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,9 @@ end
# #16356
@test_parseerror "0xapi"

# #60189
@test_parseerror "0x1p3.2"

# #22523 #22712
@test_parseerror "a?b:c"
@test_parseerror "a ?b:c"
Expand Down