Skip to content

Commit

Permalink
Fix dialyzer warning
Browse files Browse the repository at this point in the history
  • Loading branch information
sabiwara committed Jan 3, 2024
1 parent 3974395 commit 02f659f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

## Dev

### Bug fixes

- Fix `Aja.OrdMap.t/2:t` type spec
- Fix `improper_list_constr` dialyzer warning in `Aja.ord/1`

## v0.6.3 (2024-01-03)

### Enhancements

- Stop using an opaque type for `Aja.Vector.t/1:t` to enable pattern-matching.
Rely on documentation instead, like `Aja.OrdMap.t/2:t`. Thanks @MegaRedHand!

Expand Down
6 changes: 5 additions & 1 deletion lib/ord_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,11 @@ defmodule Aja.OrdMap do
end

vector_ast = RawVector.from_list_ast(key_values)
map_ast = {:%{}, [], Enum.map(map, fn {k, [i | v]} -> {k, [{:|, [], [i, v]}]} end)}
kvs_ast = Enum.map(map, fn {k, [i | v]} -> {k, quote(do: [unquote(i) | unquote(v)])} end)

# "generated: true" to prevent dialyzer from raising `improper_list_constr` warnings.
# these warnings might be removed eventually: https://github.com/erlang/otp/issues/5937
map_ast = quote generated: true, do: %{unquote_splicing(kvs_ast)}

quote do
%unquote(__MODULE__){__ord_map__: unquote(map_ast), __ord_vector__: unquote(vector_ast)}
Expand Down

0 comments on commit 02f659f

Please sign in to comment.