Skip to content

Commit 1351d70

Browse files
authored
Fix error in hooks when parsing incomplete x. (#385)
Also add another fuzzing tool
1 parent e3df852 commit 1351d70

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/hooks.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ function _has_nested_error(ex)
127127
else
128128
return any(_has_nested_error(e) for e in ex.args)
129129
end
130+
elseif ex isa QuoteNode
131+
return _has_nested_error(ex.value)
130132
else
131133
return false
132134
end

test/fuzz_test.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,10 @@ function product_token_fuzz(tokens, N)
969969
(join(ts) for ts in Iterators.product([tokens for _ in 1:N]...))
970970
end
971971

972+
function random_token_fuzz(tokens, ntokens, ntries)
973+
(join(rand(tokens, ntokens)) for _ in 1:ntries)
974+
end
975+
972976
"""
973977
Fuzz test parser against randomly generated binary strings
974978
"""

test/hooks.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ end
6666
LineNumberNode(4, "somefile"),
6767
]
6868
@test Meta.isexpr(ex.args[6], :error)
69+
70+
ex = JuliaSyntax.core_parser_hook("x.", "somefile", 0, 0, :all)[1]
71+
@test ex.head == :toplevel
72+
@test ex.args[2].head == :incomplete
6973
end
7074

7175
@testset "enable_in_core!" begin

0 commit comments

Comments
 (0)