Bugs in Erlang code -- a common one?

Kostis Sagonas kostis@REDACTED
Sun Mar 20 18:49:37 CET 2005


Some of the bugs in Erlang code that we have discovered using the
new type inference (albeit currently the hard way) are really
subtle and extend beyond simple type clashes.

For example, the code of snmp/src/compile/snmpc.erl at some point
reads:

-----------------------------------------------------------------------
define_cols(...) ->
    SIok = case SubIndex of
               {Parent,[_SI]} when Parent =/= NameOfEntry ->
                   snmpc_lib:print_error(
                     "Invalid parent ~p for table column ~p (should be ~p).",
                     [Parent,NameOfCol,NameOfEntry],Oline),
                   false;
               {NameOfEntry,[SI]} when SI =/= SubIndex ->
                   snmpc_lib:print_error(
                     "Invalid column number ~p for column ~p.",
                     [SI,NameOfCol],Oline),
                   false;
               {NameOfEntry,[SubIndex]} ->
                   ok;
    ....
------------------------------------------------------------------------

and a moment's thought can reveal that there is something fishy here.

By the way, this is the second occurrence of this type of error that
we've found this week in OTP code (there was a similar one in gen_fsm).
I am wondering how frequent is this type of error in Erlang code and
whether this type of error can eventually be detected by the BEAM compiler.

Best,
Kostis.




More information about the erlang-questions mailing list