summaryrefslogtreecommitdiff
path: root/lib/stdlib/test/erl_pp_SUITE.erl
diff options
context:
space:
mode:
authorHans Bolinder <hasse@erlang.org>2020-01-28 15:40:10 +0100
committerHans Bolinder <hasse@erlang.org>2020-01-30 09:51:02 +0100
commit7e09b923a247b26552bb8e4f787c06d21ed60733 (patch)
tree85d8c4ee17da35c3296ef68ea688f1cdc2216961 /lib/stdlib/test/erl_pp_SUITE.erl
parent18f554ac88558678c0b94692ff3206e0e7ab0b13 (diff)
downloaderlang-7e09b923a247b26552bb8e4f787c06d21ed60733.tar.gz
stdlib: Fix precedence bug regarding '::'
A corner case: if a type `t()' is annotated as in `N1 :: (N2 :: t())' (where `N1' and `N2' are annotations and not type variables), parentheses are now inserted correctly by erl_pp.
Diffstat (limited to 'lib/stdlib/test/erl_pp_SUITE.erl')
-rw-r--r--lib/stdlib/test/erl_pp_SUITE.erl18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index c0cfd26925..e6ff141b5f 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2019. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2020. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -52,7 +52,8 @@
otp_6321/1, otp_6911/1, otp_6914/1, otp_8150/1, otp_8238/1,
otp_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1,
otp_10302/1, otp_10820/1, otp_11100/1, otp_11861/1, pr_1014/1,
- otp_13662/1, otp_14285/1, otp_15592/1, otp_15751/1, otp_15755/1]).
+ otp_13662/1, otp_14285/1, otp_15592/1, otp_15751/1, otp_15755/1,
+ otp_16435/1]).
%% Internal export.
-export([ehook/6]).
@@ -82,7 +83,7 @@ groups() ->
[otp_6321, otp_6911, otp_6914, otp_8150, otp_8238,
otp_8473, otp_8522, otp_8567, otp_8664, otp_9147,
otp_10302, otp_10820, otp_11100, otp_11861, pr_1014, otp_13662,
- otp_14285, otp_15592, otp_15751, otp_15755]}].
+ otp_14285, otp_15592, otp_15751, otp_15755, otp_16435]}].
init_per_suite(Config) ->
Config.
@@ -1261,6 +1262,17 @@ otp_15755(_Config) ->
" 'sf s sdf', [], {}, {[]}}.", [])),
ok.
+otp_16435(_Config) ->
+ CheckF = fun(S) -> S = lists:flatten(parse_and_pp_forms(S, [])) end,
+ CheckF("-type t() :: A :: integer().\n"),
+ CheckF("-type t() :: A :: (B :: integer()).\n"),
+ CheckF("-type t() :: {A :: (B :: integer())}.\n"),
+ CheckF("-record(r,{f :: {A :: (B :: integer())}}).\n"),
+ CheckF("-record(r,{f = 3 :: {A :: (B :: integer())}}).\n"),
+ CheckF("-type t() :: #r{f :: A :: (B :: integer())}.\n"),
+ CheckF("-spec t(X) -> X when X :: Y :: (Z :: #r{}).\n"),
+ ok.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
compile(Config, Tests) ->