Skip to content

Commit e3df852

Browse files
authored
Fix crash with empty macro name when parsing "@(" (#382)
1 parent cfdac5f commit e3df852

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/parser.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,9 @@ function fix_macro_name_kind!(ps::ParseState, macro_name_position, name_kind=not
23162316
elseif k == K"parens"
23172317
# @(A) x ==> (macrocall (parens @A) x)
23182318
macro_name_position = first_child_position(ps, macro_name_position)
2319+
if macro_name_position == NO_POSITION
2320+
return
2321+
end
23192322
k = peek_behind(ps, macro_name_position).kind
23202323
elseif k == K"error"
23212324
# Error already reported in parse_macro_name

test/parser.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ parsestmt_test_specs = [
999999
# shouldn't crash
10001000
"@(x y)" => "(macrocall (parens @x (error-t y)))"
10011001
"|(&\nfunction" => "(call | (& (function (error (error)) (block (error)) (error-t))) (error-t))"
1002+
"@(" => "(macrocall (parens (error-t)))"
1003+
"x = @(" => "(= x (macrocall (parens (error-t))))"
10021004

10031005
# The following is currently broken but at least the parser shouldn't
10041006
# crash.

0 commit comments

Comments
 (0)