Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map type inference not working when map creation expression is not an argument #432

Closed
erszcz opened this issue Jul 25, 2022 · 0 comments · Fixed by #457
Closed

Map type inference not working when map creation expression is not an argument #432

erszcz opened this issue Jul 25, 2022 · 0 comments · Fixed by #457
Labels

Comments

@erszcz
Copy link
Collaborator

erszcz commented Jul 25, 2022

As a followup to #429 I've stumbled upon test/should_fail/covariant_map_keys_fail.erl. There's no error reported for kaboom/0 by default (even with the --infer flag), but there is if we apply the following change:

$ git diff
diff --git a/test/should_fail/covariant_map_keys_fail.erl b/test/should_fail/covariant_map_keys_fail.erl
index 99c5883..98e38f0 100644
--- a/test/should_fail/covariant_map_keys_fail.erl
+++ b/test/should_fail/covariant_map_keys_fail.erl
@@ -10,4 +10,6 @@ good(#{ good := X }) -> X.
 not_good(M) -> good(M). %% This call should fail

 -spec kaboom() -> integer().
-kaboom() -> not_good(#{ bad => 0 }).
+kaboom() ->
+    M = #{ bad => 0 },
+    not_good(M).

This shows that map type inference does not always work as expected. It might or might not be related to #378. I have a hunch it's related, as it's inference of a nested map creation expression which doesn't work as expected, not a top-level one.

@erszcz erszcz added the bug label Jul 25, 2022
@erszcz erszcz changed the title Map type inference not working when map creation expression is an argument Map type inference not working when map creation expression is not an argument Sep 17, 2022
erszcz added a commit to erszcz/Gradualizer that referenced this issue Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant