Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly abort macro parsing in dotted generators #369

Merged
merged 1 commit into from
Feb 6, 2023
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
4 changes: 2 additions & 2 deletions src/components/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ function parse_operator_dot(ps::ParseState, ret::EXPR, op::EXPR)
if kindof(ps.nt) === Tokens.LPAREN
@static if VERSION > v"1.1-"
iserred = kindof(ps.ws) != Tokens.EMPTY_WS
sig = @default ps parse_call(ps, ret)
sig = @default ps @closer ps :for_generator parse_call(ps, ret)
nextarg = EXPR(:tuple, sig.args[2:end], sig.trivia)
if iserred
nextarg = mErrorToken(ps, nextarg, UnexpectedWhiteSpace)
end
else
sig = @default ps parse_call(ps, ret)
sig = @default ps @closer ps :for_generator parse_call(ps, ret)
nextarg = EXPR(:tuple, sig.args[2:end], sig.trivia)
end
elseif iskeyword(ps.nt) || both_symbol_and_op(ps.nt)
Expand Down
2 changes: 2 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ end
@test ":(@foo bar baz bat)" |> test_expr
@test ":(@foo bar for i in j end)" |> test_expr
@test "(@foo bar for i in j end)" |> test_expr
@test "foo(@foo bar for i in j)" |> test_expr
@test "foo.(@foo bar for i in j)" |> test_expr
@test CSTParser.parse("@__DIR__\n\nx", true)[1].span == 8

if VERSION >= v"1.8.0-"
Expand Down