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
2 changes: 1 addition & 1 deletion lib/spitfire.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,7 @@ defmodule Spitfire do
parser = Map.put(parser, :nesting, 0)

{exprs, parser} =
while2 peek_token(parser) not in [:end, :")", :block_identifier] <- parser do
while2 peek_token(parser) not in [:end, :eof, :")", :block_identifier] <- parser do
parser = parser |> next_token() |> eat_eoe()
{ast, parser} = parse_expression(parser, @lowest, false, false, true)

Expand Down
21 changes: 21 additions & 0 deletions test/spitfire_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3444,6 +3444,27 @@ defmodule SpitfireTest do
{:k, [line: 1, column: 49], nil}}
]}, [{[line: 1, column: 46], "syntax error"}]}
end

test "stab expression with fn and stray closing delimiter does not exhaust fuel" do
assert Spitfire.parse("a -> b -> fn} -> c") ==
{:error,
[
{:->, [line: 1, column: 3], [[{:a, [line: 1, column: 1], nil}], nil]},
{:->, [line: 1, column: 8],
[
[],
{:fn, [line: 1, column: 11],
[
{:__block__, [error: true, line: 1, column: 13], []},
{:->, [line: 1, column: 15], [[], {:c, [line: 1, column: 18], nil}]}
]}
]}
],
[
{[line: 1, column: 13], "unknown token: }"},
{[line: 1, column: 11], "missing closing end for anonymous function"}
]}
end
end

describe "&parse_with_comments/2" do
Expand Down
Loading