aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorMagnus Lång <[email protected]>2016-02-28 00:17:48 +0100
committerHans Bolinder <[email protected]>2016-04-28 16:16:09 +0200
commitebd967522612333e52a884181e6132b1ba7e5239 (patch)
treecd12d37cd4fe9d375cf15acbad8d08e5a4542af5 /lib/compiler
parente3ac51b173585f84c397ae38c27d772be2d308c6 (diff)
downloadotp-ebd967522612333e52a884181e6132b1ba7e5239.tar.gz
otp-ebd967522612333e52a884181e6132b1ba7e5239.tar.bz2
otp-ebd967522612333e52a884181e6132b1ba7e5239.zip
dialyzer: Unfold cerl patterns containing maps
Dialyzer relies heavily on the assumption that the type of a literal that is used as a pattern is the type of any value that can match that pattern. For maps, that is not true, and it was causing bad analysis results. A new help function dialyzer_utils:refold_pattern/1 identifies maps in literal patterns, and unfolds and labels them, allowing them to be properly analysed.
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/cerl.erl7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/compiler/src/cerl.erl b/lib/compiler/src/cerl.erl
index 37ec4e97c9..6dc162db40 100644
--- a/lib/compiler/src/cerl.erl
+++ b/lib/compiler/src/cerl.erl
@@ -135,7 +135,7 @@
ann_c_map_pattern/2,
map_pair_op/1,map_pair_key/1,map_pair_val/1,
update_c_map_pair/4,
- c_map_pair/2,
+ c_map_pair/2, c_map_pair_exact/2,
ann_c_map_pair/4
]).
@@ -1694,6 +1694,11 @@ map_pair_op(#c_map_pair{op=Op}) -> Op.
c_map_pair(Key,Val) ->
#c_map_pair{op=#c_literal{val=assoc},key=Key,val=Val}.
+-spec c_map_pair_exact(cerl(), cerl()) -> c_map_pair().
+
+c_map_pair_exact(Key,Val) ->
+ #c_map_pair{op=#c_literal{val=exact},key=Key,val=Val}.
+
-spec ann_c_map_pair([term()], cerl(), cerl(), cerl()) ->
c_map_pair().