1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
-module(badmap_17).
-export([update/1]).
%% Compile this source file with OTP 17.0.
update(Map) ->
try
update_1(Map),
error(update_did_not_fail)
catch
error:{badmap,Map} ->
ok
end,
try
update_2(Map),
error(update_did_not_fail)
catch
error:{badmap,Map} ->
ok
end,
try
update_3(Map),
error(update_did_not_fail)
catch
error:{badmap,Map} ->
ok
end,
ok = update_4(Map),
ok = update_5(Map),
ok.
update_1(M) ->
M#{a=>42}.
update_2(M) ->
M#{a:=42}.
update_3(M) ->
id(M),
M#{a=>42}.
update_4(M) when M#{a=>b} =:= M ->
did_not_fail;
update_4(_) ->
ok.
update_5(M) ->
id(M),
case id(true) of
true when M#{a=>b} =:= M ->
did_not_fail;
true ->
ok
end.
id(I) ->
I.
|