Skip to content

Commit

Permalink
Fix crash with empty macro name when parsing "@(" (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
c42f authored Nov 6, 2023
1 parent cfdac5f commit e3df852
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,9 @@ function fix_macro_name_kind!(ps::ParseState, macro_name_position, name_kind=not
elseif k == K"parens"
# @(A) x ==> (macrocall (parens @A) x)
macro_name_position = first_child_position(ps, macro_name_position)
if macro_name_position == NO_POSITION
return
end
k = peek_behind(ps, macro_name_position).kind
elseif k == K"error"
# Error already reported in parse_macro_name
Expand Down
2 changes: 2 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,8 @@ parsestmt_test_specs = [
# shouldn't crash
"@(x y)" => "(macrocall (parens @x (error-t y)))"
"|(&\nfunction" => "(call | (& (function (error (error)) (block (error)) (error-t))) (error-t))"
"@(" => "(macrocall (parens (error-t)))"
"x = @(" => "(= x (macrocall (parens (error-t))))"

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

0 comments on commit e3df852

Please sign in to comment.