[erlang-bugs] lint_module crash on +check_untyped_records

Kostis Sagonas kostis@REDACTED
Thu Mar 4 18:52:15 CET 2010


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.


More information about the erlang-bugs mailing list