-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #457 from erszcz/fix-map-type-inference
Fix map type inference
- Loading branch information
Showing
4 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
-module(covariant_map_keys_fail). | ||
|
||
-compile([nowarn_unused_function]). | ||
-export([not_good/1]). | ||
|
||
-spec good(#{ good := A }) -> A. | ||
good(#{ good := X }) -> X. | ||
-spec good(#{good := A}) -> A. | ||
good(#{good := X}) -> X. | ||
|
||
-spec not_good(#{good | bad := A}) -> A. | ||
not_good(M) -> good(M). %% This call should fail | ||
|
||
-spec kaboom() -> integer(). | ||
kaboom() -> not_good(#{ bad => 0 }). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(map_infer_pass). | ||
|
||
-export([not_good/1, | ||
kaboom1/0, | ||
kaboom2/0]). | ||
|
||
-gradualizer([infer]). | ||
|
||
-spec not_good(#{good | bad := integer()}) -> integer(). | ||
not_good(#{good := _}) -> 0. | ||
|
||
-spec kaboom1() -> integer(). | ||
kaboom1() -> | ||
M = #{bad => 0}, | ||
not_good(M). | ||
|
||
-spec kaboom2() -> integer(). | ||
kaboom2() -> | ||
not_good(#{bad => 0}). |