Skip to content

Commit 40b3fb9

Browse files
committed
More generally refuse to work with map update syntax.
Fixes #67
1 parent 220e602 commit 40b3fb9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: lib/matcha/rewrite/expression.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ defmodule Matcha.Rewrite.Expression do
8888

8989
# Maps should refuse to work with update syntax
9090
defp do_rewrite_literals(
91-
{:%{}, _, [{:|, _, [{:%{}, _, _map_elements}, _map_updates]}]} = map_ast,
91+
{:%{}, _, [{:|, _, _}]} = map_ast,
9292
rewrite
9393
) do
9494
raise_map_update_error!(rewrite, map_ast)

Diff for: test/unit/matcha/rewrite/bodies_test.exs

+10
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ defmodule Matcha.Rewrite.Bodies.UnitTest do
164164
end
165165
end
166166
end
167+
168+
assert_raise Matcha.Rewrite.Error, ~r"cannot use map update syntax in match specs", fn ->
169+
defmodule test_module_name(context) do
170+
import Matcha
171+
172+
spec do
173+
{id, map} -> {id, %{ map | key: :value}}
174+
end
175+
end
176+
end
167177
end
168178
end
169179

0 commit comments

Comments
 (0)