aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/erl_pp_SUITE.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2011-03-22 13:57:30 +0100
committerHans Bolinder <[email protected]>2011-03-22 13:57:30 +0100
commitb420086b983b934b231323a682e676bf149e7bf8 (patch)
treeda8d5a0aa06f4642de871762ebd5abd8b76d4a84 /lib/stdlib/test/erl_pp_SUITE.erl
parentf861b4fdb3fd39e35f2951c53a73b30a98c7f973 (diff)
downloadotp-b420086b983b934b231323a682e676bf149e7bf8.tar.gz
otp-b420086b983b934b231323a682e676bf149e7bf8.tar.bz2
otp-b420086b983b934b231323a682e676bf149e7bf8.zip
Fix a bug concerning record field types
The default value 'undefined' was added to records field types in such a way that the result was not always a well-formed type. This bug has been fixed. --- erl_pp has since OTP-8150 formatted types so that 'undefined' was removed from union types assigned to record fields. Since one cannot distinguish between 'undefined' added by the parser or supplied by the user, a side effect was that user supplied 'undefined's were also removed. Now the pretty printer shows 'undefined' even if added by the parser. This is a minor issue.
Diffstat (limited to 'lib/stdlib/test/erl_pp_SUITE.erl')
-rw-r--r--lib/stdlib/test/erl_pp_SUITE.erl24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/stdlib/test/erl_pp_SUITE.erl b/lib/stdlib/test/erl_pp_SUITE.erl
index 822886cb8a..bc811355ab 100644
--- a/lib/stdlib/test/erl_pp_SUITE.erl
+++ b/lib/stdlib/test/erl_pp_SUITE.erl
@@ -48,7 +48,7 @@
neg_indent/1,
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_8473/1, otp_8522/1, otp_8567/1, otp_8664/1, otp_9147/1]).
%% Internal export.
-export([ehook/6]).
@@ -79,7 +79,7 @@ groups() ->
{attributes, [], [misc_attrs, import_export]},
{tickets, [],
[otp_6321, otp_6911, otp_6914, otp_8150, otp_8238,
- otp_8473, otp_8522, otp_8567, otp_8664]}].
+ otp_8473, otp_8522, otp_8567, otp_8664, otp_9147]}].
init_per_suite(Config) ->
Config.
@@ -1047,6 +1047,26 @@ otp_8664(Config) when is_list(Config) ->
ok.
+otp_9147(doc) ->
+ "OTP_9147. Create well-formed types when adding 'undefined'.";
+otp_9147(suite) -> [];
+otp_9147(Config) when is_list(Config) ->
+ FileName = filename('otp_9147.erl', Config),
+ C1 = <<"-module(otp_9147).\n"
+ "-export_type([undef/0]).\n"
+ "-record(undef, {f1 :: F1 :: a | b}).\n"
+ "-type undef() :: #undef{}.\n">>,
+ ?line ok = file:write_file(FileName, C1),
+ ?line {ok, _, []} =
+ compile:file(FileName, [return,'P',{outdir,?privdir}]),
+ PFileName = filename('otp_9147.P', Config),
+ ?line {ok, Bin} = file:read_file(PFileName),
+ %% The parentheses around "F1 :: a | b" are new (bugfix).
+ ?line true =
+ lists:member("-record(undef,{f1 :: undefined | (F1 :: a | b)}).",
+ string:tokens(binary_to_list(Bin), "\n")),
+ ok.
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
compile(Config, Tests) ->