aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_parse.yrl
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/src/erl_parse.yrl
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/src/erl_parse.yrl')
-rw-r--r--lib/stdlib/src/erl_parse.yrl10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index bb4b18cf9b..15b45d72f4 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -2,7 +2,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1996-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -757,7 +757,8 @@ record_fields([{typed,Expr,TypeInfo}|Fields]) ->
{atom, La, _} ->
case has_undefined(TypeInfo) of
false ->
- lift_unions(abstract(undefined, La), TypeInfo);
+ TypeInfo2 = maybe_add_paren(TypeInfo),
+ lift_unions(abstract(undefined, La), TypeInfo2);
true ->
TypeInfo
end
@@ -778,6 +779,11 @@ has_undefined({type,_,union,Ts}) ->
has_undefined(_) ->
false.
+maybe_add_paren({ann_type,L,T}) ->
+ {paren_type,L,[{ann_type,L,T}]};
+maybe_add_paren(T) ->
+ T.
+
term(Expr) ->
try normalise(Expr)
catch _:_R -> ret_err(?line(Expr), "bad attribute")