diff options
author | Hans Bolinder <[email protected]> | 2015-11-17 14:09:59 +0100 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2015-12-07 09:41:25 +0100 |
commit | b8a5a201389c117aaa8ddfa387dcb11fb6f5ae4a (patch) | |
tree | 8186e2248f56ae30d8b24544d5f5a7b04cb080c2 /lib/stdlib/src/erl_pp.erl | |
parent | 0ad8b47ce2ec578eab64896a3ba8af3f71ce2fd1 (diff) | |
download | otp-b8a5a201389c117aaa8ddfa387dcb11fb6f5ae4a.tar.gz otp-b8a5a201389c117aaa8ddfa387dcb11fb6f5ae4a.tar.bz2 otp-b8a5a201389c117aaa8ddfa387dcb11fb6f5ae4a.zip |
stdlib: Correct pretty-printing of map types
Add parentheses around annotated type union elements in map pair
types. The bug was introduced in Erlang/OTP 18.0.
Diffstat (limited to 'lib/stdlib/src/erl_pp.erl')
-rw-r--r-- | lib/stdlib/src/erl_pp.erl | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl index 9c812395e3..c5177aca90 100644 --- a/lib/stdlib/src/erl_pp.erl +++ b/lib/stdlib/src/erl_pp.erl @@ -347,16 +347,8 @@ map_type(Fs) -> map_pair_types(Fs) -> tuple_type(Fs, fun map_pair_type/2). -map_pair_type({type,_Line,map_field_assoc,[Ktype,Vtype]}, Prec) -> - map_assoc_typed(ltype(Ktype), Vtype, Prec). - -map_assoc_typed(B, {type,_,union,Ts}, Prec) -> - {first,[B,$\s],{seq,[],[],[],map_assoc_union_type(Ts, Prec)}}; -map_assoc_typed(B, Type, Prec) -> - {list,[{cstep,[B," =>"],ltype(Type, Prec)}]}. - -map_assoc_union_type([T|Ts], Prec) -> - [[leaf("=> "),ltype(T)] | ltypes(Ts, fun union_elem/2, Prec)]. +map_pair_type({type,_Line,map_field_assoc,[KType,VType]}, Prec) -> + {list,[{cstep,[ltype(KType, Prec),leaf(" =>")],ltype(VType, Prec)}]}. record_type(Name, Fields) -> {first,[record_name(Name)],field_types(Fields)}. @@ -371,9 +363,6 @@ typed(B, Type) -> {_L,_P,R} = type_inop_prec('::'), {list,[{cstep,[B,' ::'],ltype(Type, R)}]}. -union_elem(T, Prec) -> - [leaf(" | "),ltype(T, Prec)]. - tuple_type(Ts, F) -> {seq,${,$},[$,],ltypes(Ts, F, 0)}. |