Skip to content

Commit

Permalink
Fix parsing of -1::Int - signed literals with type assertions (#462)
Browse files Browse the repository at this point in the history
This syntax is normally not something you'd use, but it's very useful
for `ccall`. Previously the parser just crashed on this kind of input -
a bug which is also present in the old parser.
  • Loading branch information
c42f authored Jul 16, 2024

Unverified

This user has not yet uploaded their public signing key.
1 parent 94b15ac commit ebcc56a
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parser.jl
Original file line number Diff line number Diff line change
@@ -1211,6 +1211,7 @@ function parse_unary(ps::ParseState)
# -2*x ==> (call-i -2 * x)
# +0xff ==> 0xff
bump_glue(ps, kind(t2), EMPTY_FLAGS)
parse_factor_with_initial_ex(ps, mark)
end
return
end
1 change: 1 addition & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
@@ -212,6 +212,7 @@ tests = [
"-0b10010" => "(call-pre - 0x12)"
"-0o22" => "(call-pre - 0x12)"
"-0x12" => "(call-pre - 0x12)"
"-1::T" => "(::-i -1 T)"
# Standalone dotted operators are parsed as (|.| op)
".+" => "(. +)"
".+\n" => "(. +)"

0 comments on commit ebcc56a

Please sign in to comment.