From 388146d35288581c8fb93deee7dbb55e065d4c29 Mon Sep 17 00:00:00 2001 From: Claire Foster Date: Tue, 11 Jun 2024 14:46:54 +1000 Subject: [PATCH] Fix parsing of `-1::Int` - signed literals with type assertions 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. --- src/parser.jl | 1 + test/parser.jl | 1 + 2 files changed, 2 insertions(+) diff --git a/src/parser.jl b/src/parser.jl index 34666b59..9e02928e 100644 --- a/src/parser.jl +++ b/src/parser.jl @@ -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 diff --git a/test/parser.jl b/test/parser.jl index 3ac3ed36..1e4baa66 100644 --- a/test/parser.jl +++ b/test/parser.jl @@ -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" => "(. +)"