Skip to content

Commit

Permalink
better refinment of maps: test
Browse files Browse the repository at this point in the history
Summary: a test for the fix in next diff

Reviewed By: VLanvin

Differential Revision: D53179540

fbshipit-source-id: bc9189877314e9460c4fe177f26c85a76a94d674
  • Loading branch information
ilya-klyuchnikov authored and facebook-github-bot committed Jan 29, 2024
1 parent 22c719e commit 761c4ca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eqwalizer/test_projects/eqwater/src/eqwater_maps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
23 changes: 23 additions & 0 deletions eqwalizer/test_projects/eqwater/src/eqwater_maps.erl.check
Original file line number Diff line number Diff line change
Expand Up @@ -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. | |

0 comments on commit 761c4ca

Please sign in to comment.