From 51a815cd65ae5f601447efb1dc2c0186c45a5bbe Mon Sep 17 00:00:00 2001 From: sabiwara Date: Wed, 3 Jan 2024 13:29:36 +0900 Subject: [PATCH] Fix dialyzer warning --- CHANGELOG.md | 7 +++++++ lib/ord_map.ex | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 324e0f8..f847261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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! diff --git a/lib/ord_map.ex b/lib/ord_map.ex index 84d7ed6..f32b90c 100644 --- a/lib/ord_map.ex +++ b/lib/ord_map.ex @@ -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)}