Skip to content
Open
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
8 changes: 3 additions & 5 deletions lib/spitfire.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1698,11 +1698,9 @@ defmodule Spitfire do
{parser, is_valid} = validate_peek(parser, current_token_type(parser))

if is_valid do
while peek_token(parser) not in terminals && calc_prec(parser, associativity, precedence) <- {left, parser} do
case peek_token_type(parser) do
:. -> parse_dot_expression(next_token(parser), left)
_ -> {left, parser}
end
while peek_token(parser) not in terminals && peek_token(parser) == :. &&
calc_prec(parser, associativity, precedence) <- {left, parser} do
parse_dot_expression(next_token(parser), left)
end
else
{left, parser}
Expand Down
10 changes: 10 additions & 0 deletions test/spitfire_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,16 @@ defmodule SpitfireTest do
]
}
end

test "incomplete struct in match expression" do
assert Spitfire.parse("%Foo = x") ==
{:error,
{:%, [line: 1, column: 1],
[
{:__aliases__, [last: [line: 1, column: 2], line: 1, column: 2], [:Foo]},
{:%{}, [closing: [line: 1, column: 8], line: 1, column: 6], [{:x, [line: 1, column: 8], nil}]}
]}, [{[line: 1, column: 8], "missing closing brace for struct"}]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be expecting the error message to say something about missing an opening brace for the struct. There might be something else not going correct here. I don't think %Foo is valid syntax by itself.

end
end

describe "&parse_with_comments/2" do
Expand Down
Loading