diff options
author | Björn Gustavsson <[email protected]> | 2018-08-22 10:17:50 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-08-22 10:35:43 +0200 |
commit | e8deb9f8ff3cb32286ca9b87a36b23aadffd1a49 (patch) | |
tree | 75eef2c88577234beb177537bab276d85cb66ed3 | |
parent | 924f1573adb661f5f15123b0e7af80bb233418be (diff) | |
download | otp-e8deb9f8ff3cb32286ca9b87a36b23aadffd1a49.tar.gz otp-e8deb9f8ff3cb32286ca9b87a36b23aadffd1a49.tar.bz2 otp-e8deb9f8ff3cb32286ca9b87a36b23aadffd1a49.zip |
beam_validator: Infer the type of the map argument for is_map_key/2
Make sure that beam_validator considers a call to is_map_key/2
followed by an update of the same map without an is_map/1 test
safe. (This situation will probably not be encountered when
using the compiler in OTP 21, but better safe than sorry.)
-rw-r--r-- | lib/compiler/src/beam_validator.erl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_validator.erl b/lib/compiler/src/beam_validator.erl index a0eef826ce..fb2e7df65c 100644 --- a/lib/compiler/src/beam_validator.erl +++ b/lib/compiler/src/beam_validator.erl @@ -565,6 +565,12 @@ valfun_4({bif,map_get,{f,Fail},[_Key,Map]=Src,Dst}, Vst0) -> Vst = set_type(map, Map, Vst1), Type = propagate_fragility(term, Src, Vst), set_type_reg(Type, Dst, Vst); +valfun_4({bif,is_map_key,{f,Fail},[_Key,Map]=Src,Dst}, Vst0) -> + validate_src(Src, Vst0), + Vst1 = branch_state(Fail, Vst0), + Vst = set_type(map, Map, Vst1), + Type = propagate_fragility(bool, Src, Vst), + set_type_reg(Type, Dst, Vst); valfun_4({bif,Op,{f,Fail},Src,Dst}, Vst0) -> validate_src(Src, Vst0), Vst = branch_state(Fail, Vst0), |