diff --git a/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl b/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl index 9e6eb82..a3be5e0 100644 --- a/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl +++ b/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl @@ -40,3 +40,11 @@ map_occ_06_neg(V) -> V. -> #{b := integer()}. map_occ_07_neg(#{a := _}) -> #{b => 0}; map_occ_07_neg(M) -> M. + +-type foo() :: #{} | #{required := binary(), optional => binary()}. + +-spec add_optional(foo(), binary()) -> foo(). +add_optional(Foo = #{required := _R1}, Optional) -> + Foo#{optional => Optional}; +add_optional(Z, _) -> + Z. diff --git a/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl.check b/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl.check index bafc427..85fd06b 100644 --- a/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl.check +++ b/eqwalizer/test_projects/eqwater/src/eqwater_maps.erl.check @@ -68,3 +68,26 @@ map_occ_07_neg(M) -> M. | | M. | | - b := ... | | + c := ... | | } + | | +-type foo() :: #{} | #{required := binary(…… | + | | +-spec add_optional(foo(), binary()) -> foo…… | +add_optional(Foo = #{required := _R1}, Opt…… ERROR | + Foo#{optional => Optional}; | | ..#{..}. + | | Expression has type: #S{optional := binary()} | #S{optional := binary(), required := binary()} + | | Context expected type: foo() + | | + | | #S{optional := binary()} | #S{optional := binary(), required := binary()} is not compatible with foo() + | | because + | | #S{optional := binary()} | #S{optional := binary(), required := binary()} is not compatible with #S{} | #S{optional => binary(), required := binary()} + | | because + | | #S{optional := binary()} is not compatible with #S{} | #S{optional => binary(), required := binary()} + | | because + | | #S{optional := binary()} is not compatible with #S{} + | | These associations do not match: + | | + | | #S{ + | | + optional := ... + | | } +add_optional(Z, _) -> | | + Z. | |