Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  lint_module crash on +check_untyped_records

lordnull
Posted: Thu Mar 04, 2010 4:11 pm Reply with quote
Joined: 03 Mar 2010 Posts: 2
Attempting to compile a module that defines a type dependant on an undefined record with the +warn_untyped_record flag causes erl_lint to crash with reason badarg. Perhaps a better behavior is to report the undefined record instead.

This has been tested on R13B03 on OS 10.6.2.

To reproduce the behavior:

Create the file badmod.erl:

Code:

-module(badmod).

-type(test() :: #arec{}).


Compile:
erlc +warn_untyped_record badmod.erl


This should cause:

badmod.erl:none: internal error in lint_module;
crash reason: {badarg,[{dict,fetch,
[arec,
{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],
[],[],[]},
{{[],[],[],[],[],[],[],[],[],[],[],[],[],
[],[],[]}}}]},
{erl_lint,'-check_untyped_records/2-fun-1-',3},
{lists,foldl,3},
{erl_lint,post_traversal_check,2},
{erl_lint,module,3},
{compile,lint_module,1},
{compile,'-internal_comp/4-anonymous-1-',2},
{compile,fold_comp,3}]}


To resolve the error define #arec{}:

-module(badmod).

-record(arc, {id :: string()}).

-type(test() :: #arec{}).


________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist
View user's profile Send private message
Guest
Posted: Thu Mar 04, 2010 5:53 pm Reply with quote
Guest
Micah Warren wrote:
> Attempting to compile a module that defines a type dependant on an undefined record with the +warn_untyped_record flag causes erl_lint to crash with reason badarg. Perhaps a better behavior is to report the undefined record instead.

Thanks for the bug report!

This will be fixed in R14 (and will appear soon in git) but in case you
need a fix earlier it is included below although the line numbers differ.

Kostis

Index: lib/stdlib/src/erl_lint.erl
===================================================================
RCS file: /hipe/otp/lib/stdlib/src/erl_lint.erl,v
retrieving revision 1.137
diff -u -r1.137 erl_lint.erl
--- lib/stdlib/src/erl_lint.erl 4 Mar 2010 15:27:46 -0000 1.137
+++ lib/stdlib/src/erl_lint.erl 4 Mar 2010 17:48:30 -0000
@@ -1030,11 +1030,8 @@
check_untyped_records(Forms, St0) ->
case is_warn_enabled(untyped_record, St0) of
true ->
- %% One possibility is to use the names of all records
- %% RecNames = dict:fetch_keys(St0#lint.records),
- %% but I think it's better to keep those that are used by
the file
- Usage = St0#lint.usage,
- UsedRecNames = sets:to_list(Usage#usage.used_records),
+ %% Use the names of all records *defined* in the module (not
used)
+ RecNames = dict:fetch_keys(St0#lint.records),
%% these are the records with field(s) containing type info
TRecNames = [Name ||
{attribute,_,type,{{record,Name},Fields,_}}
<- Forms,
@@ -1047,7 +1044,7 @@
[] -> St; % exclude records with no fields
[_|_] -> add_warning(L, {untyped_record,
N}, St)
end
- end, St0, UsedRecNames -- TRecNames);
+ end, St0, RecNames -- TRecNames);
false ->
St0
end.

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum