Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
# as inert QuoteNode rather than in `Expr(:quote)` quasiquote
return QuoteNode(a1)
end
elseif k == K"do"
@check length(args) == 3
elseif k == K"do" && length(args) == 3
return Expr(:do, args[1], Expr(:->, args[2], args[3]))
elseif k == K"let"
a1 = args[1]
Expand Down Expand Up @@ -439,6 +438,10 @@ function _internal_node_to_Expr(source, srcrange, head, childranges, childheads,
args[i] = ai.value
end
end
elseif k == K"wrapper"
# This should only happen for errors wrapped next to what should have
# been single statements or atoms - represent these as blocks.
headsym = :block
end

return Expr(headsym, args...)
Expand Down
2 changes: 2 additions & 0 deletions test/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,8 @@
LineNumberNode(1), Expr(:error, :b))
@test parsestmt("(x", ignore_errors=true) ==
Expr(:block, :x, Expr(:error))
@test parsestmt("x do", ignore_errors=true) ==
Expr(:block, :x, Expr(:error, Expr(:do)))
end

@testset "import" begin
Expand Down