aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2010-03-17 09:11:23 +0000
committerErlang/OTP <[email protected]>2010-03-17 09:11:23 +0000
commitba24a5d2f839bb0cfef00bdb8bf74744e77ed587 (patch)
treeb2a7b8998673cdcdd91388a9404f0c261e5dda4a /lib/stdlib/src
parent4b8723ee1e17264d15cc89e26e2293605280f319 (diff)
downloadotp-ba24a5d2f839bb0cfef00bdb8bf74744e77ed587.tar.gz
otp-ba24a5d2f839bb0cfef00bdb8bf74744e77ed587.tar.bz2
otp-ba24a5d2f839bb0cfef00bdb8bf74744e77ed587.zip
OTP-8522 Avoid duplicated 'undefined' in record field types
The Erlang parser no longer duplicates the singleton type undefined in the type of record fields without initial value.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/erl_parse.yrl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index 435464227f..ea91ec5927 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -734,13 +734,29 @@ record_fields([{typed,Expr,TypeInfo}|Fields]) ->
case Expr of
{match, _, _, _} -> TypeInfo; %% If we have an initializer.
{atom, La, _} ->
- lift_unions(abstract(undefined, La), TypeInfo)
+ case has_undefined(TypeInfo) of
+ false ->
+ lift_unions(abstract(undefined, La), TypeInfo);
+ true ->
+ TypeInfo
+ end
end,
[{typed_record_field,Field,TypeInfo1}|record_fields(Fields)];
record_fields([Other|_Fields]) ->
ret_err(?line(Other), "bad record field");
record_fields([]) -> [].
+has_undefined({atom,_,undefined}) ->
+ true;
+has_undefined({ann_type,_,[_,T]}) ->
+ has_undefined(T);
+has_undefined({paren_type,_,[T]}) ->
+ has_undefined(T);
+has_undefined({type,_,union,Ts}) ->
+ lists:any(fun has_undefined/1, Ts);
+has_undefined(_) ->
+ false.
+
term(Expr) ->
try normalise(Expr)
catch _:_R -> ret_err(?line(Expr), "bad attribute")