diff options
author | Hans Bolinder <[email protected]> | 2010-03-09 08:34:44 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-03-09 09:37:14 +0100 |
commit | 4d64020cbefff673c840bdd5fa136fa1c570651d (patch) | |
tree | 604ff39c942a44120dca7407c122fa318b805f0f /lib | |
parent | 96015189f40635d0f617eed2b6d4d6ee773e1fd5 (diff) | |
download | otp-4d64020cbefff673c840bdd5fa136fa1c570651d.tar.gz otp-4d64020cbefff673c840bdd5fa136fa1c570651d.tar.bz2 otp-4d64020cbefff673c840bdd5fa136fa1c570651d.zip |
OTP-8503 stdlib: records with no fields is considered typed by epp
The empty record (no fields) is now considered typed.
It is more consistent than before; the base case is
the logical one.
A record is typed iff all its fields are typed.
A record is tagged 'typed' iff it is typed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/epp.erl | 2 | ||||
-rw-r--r-- | lib/stdlib/test/epp_SUITE.erl | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl index 2aa52ea84a..e1b569d389 100644 --- a/lib/stdlib/src/epp.erl +++ b/lib/stdlib/src/epp.erl @@ -176,6 +176,8 @@ parse_file(Epp) -> [{eof,Location}] end. +normalize_typed_record_fields([]) -> + {typed, []}; normalize_typed_record_fields(Fields) -> normalize_typed_record_fields(Fields, [], false). diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl index 01027ba768..3342e8f1ff 100644 --- a/lib/stdlib/test/epp_SUITE.erl +++ b/lib/stdlib/test/epp_SUITE.erl @@ -23,7 +23,7 @@ upcase_mac/1, upcase_mac_1/1, upcase_mac_2/1, variable/1, variable_1/1, otp_4870/1, otp_4871/1, otp_5362/1, pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1, - otp_8130/1, overload_mac/1, otp_8388/1, otp_8470/1]). + otp_8130/1, overload_mac/1, otp_8388/1, otp_8470/1, otp_8503/1]). -export([epp_parse_erl_form/2]). @@ -63,7 +63,7 @@ all(doc) -> all(suite) -> [rec_1, upcase_mac, predef_mac, variable, otp_4870, otp_4871, otp_5362, pmod, not_circular, skip_header, otp_6277, otp_7702, otp_8130, - overload_mac, otp_8388, otp_8470]. + overload_mac, otp_8388, otp_8470, otp_8503]. rec_1(doc) -> ["Recursive macros hang or crash epp (OTP-1398)."]; @@ -1160,6 +1160,21 @@ otp_8470(Config) when is_list(Config) -> ?line receive _ -> fail() after 0 -> ok end, ok. +otp_8503(doc) -> + ["OTP-8503. Record with no fields is considered typed."]; +otp_8503(suite) -> + []; +otp_8503(Config) when is_list(Config) -> + Dir = ?config(priv_dir, Config), + C = <<"-record(r, {}).">>, + ?line File = filename:join(Dir, "otp_8503.erl"), + ?line ok = file:write_file(File, C), + ?line {ok, List} = epp:parse_file(File, [], []), + ?line [_] = [F || {attribute,_,type,{{record,r},[],[]}}=F <- List], + file:delete(File), + ?line receive _ -> fail() after 0 -> ok end, + ok. + check(Config, Tests) -> eval_tests(Config, fun check_test/2, Tests). |