Skip to content

Commit ebcc56a

Browse files
authored
Fix parsing of -1::Int - signed literals with type assertions (#462)
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.
1 parent 94b15ac commit ebcc56a

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ function parse_unary(ps::ParseState)
12111211
# -2*x ==> (call-i -2 * x)
12121212
# +0xff ==> 0xff
12131213
bump_glue(ps, kind(t2), EMPTY_FLAGS)
1214+
parse_factor_with_initial_ex(ps, mark)
12141215
end
12151216
return
12161217
end

test/parser.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ tests = [
212212
"-0b10010" => "(call-pre - 0x12)"
213213
"-0o22" => "(call-pre - 0x12)"
214214
"-0x12" => "(call-pre - 0x12)"
215+
"-1::T" => "(::-i -1 T)"
215216
# Standalone dotted operators are parsed as (|.| op)
216217
".+" => "(. +)"
217218
".+\n" => "(. +)"

0 commit comments

Comments
 (0)