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
3 changes: 2 additions & 1 deletion src/hooks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ function core_parser_hook(code, filename::String, lineno::Int, offset::Int, opti
end
end
parse!(stream; rule=options)
pos_before_trivia = last_byte(stream)
if options === :statement
bump_trivia(stream; skip_newlines=false)
if peek(stream) == K"NewlineWs"
Expand All @@ -179,7 +180,7 @@ function core_parser_hook(code, filename::String, lineno::Int, offset::Int, opti

if any_error(stream)
tree = build_tree(SyntaxNode, stream, first_line=lineno, filename=filename)
tag = _incomplete_tag(tree, lastindex(code))
tag = _incomplete_tag(tree, pos_before_trivia)
if _has_v1_10_hooks
exc = ParseError(stream, filename=filename, first_line=lineno,
incomplete_tag=tag)
Expand Down
3 changes: 3 additions & 0 deletions test/hooks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ end
"1, " => :other
"1,\n" => :other
"1, \n" => :other
"f(1, " => :other
"[x " => :other
"( " => :other

# Reference parser fails to detect incomplete exprs in this case
"(x for y" => :other
Expand Down
Loading