aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/epp.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2015-11-30 09:26:16 +0100
committerHans Bolinder <[email protected]>2016-02-17 12:58:19 +0100
commitde9012628a6b0e97d2f1325bf2f72817f69f84ee (patch)
tree02a0ca2bff542fd5882d60f16e92b780d5599da1 /lib/stdlib/src/epp.erl
parent05a24fed7539f861c7d725829acb196a3991923c (diff)
downloadotp-de9012628a6b0e97d2f1325bf2f72817f69f84ee.tar.gz
otp-de9012628a6b0e97d2f1325bf2f72817f69f84ee.tar.bz2
otp-de9012628a6b0e97d2f1325bf2f72817f69f84ee.zip
stdlib: Modify the preprocessor as to expose typed record fields
Problem: The types of record fields have since R12B been put in a separate form by epp:parse_file(), leaving the record declaration form untyped. The separate form, however, does not follow the syntax of type declarations, and parse transforms inspecting -type() attributes need to know about the special syntax. Since the compiler stores the return value of epp:parse_file() as debug information in the abstract code chunk ("Abst" or 'abstract_code'), tools too need to know about the special syntax, if they inspect -type() attributes in abstract code. Solution: As of this commit no separate form is created by epp:parse_file(), but the type information kept in the record fields. This means that all parse transforms and all tools inspecting -record() declarations need to recognize {typed_record_field, Field, Type}. We recommend that all parse transforms and tools be updated as to recognize typed record fields. Discussion: As of OTP 19.0, the abstract form of type declarations and function specifications is documented. An (unsatisfactory) alternative to the above solution is to document two formats of the abstract form of typed record fields: one if returned by epp:parse_file(); and one if returned by, for example, epp:parse_erl_form(). Yet another (bad) alternative is to not document the format returned by epp:erl_parse(), but instead document the idempotent function epp:restore_typed_record_fields/1, and urge authors of parse transform and tools to always call this function.
Diffstat (limited to 'lib/stdlib/src/epp.erl')
-rw-r--r--lib/stdlib/src/epp.erl15
1 files changed, 1 insertions, 14 deletions
diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl
index 45f616bb02..be7c2ec346 100644
--- a/lib/stdlib/src/epp.erl
+++ b/lib/stdlib/src/epp.erl
@@ -258,20 +258,7 @@ parse_file(Ifile, Options) ->
parse_file(Epp) ->
case parse_erl_form(Epp) of
{ok,Form} ->
- case Form of
- {attribute,La,record,{Record, Fields}} ->
- case normalize_typed_record_fields(Fields) of
- {typed, NewFields} ->
- [{attribute, La, record, {Record, NewFields}},
- {attribute, La, type,
- {{record, Record}, Fields, []}}
- |parse_file(Epp)];
- not_typed ->
- [Form|parse_file(Epp)]
- end;
- _ ->
- [Form|parse_file(Epp)]
- end;
+ [Form|parse_file(Epp)];
{error,E} ->
[{error,E}|parse_file(Epp)];
{eof,Location} ->