Bug in string.erl

Joe Armstrong joe@REDACTED
Tue Nov 4 20:02:01 CET 2003


 Bug in string.erl

 This took me 45 mins to find 

 I had some variable X which I *thought* contained a list

 > string:substr(X, 1, 20).
 []

 But is was an atom ... did I get an exit - No for

 > string:substr(aa, 1, 20). 
 []

 Wow (Static type systems 1, Joe 0)

 The code in string.erl says 

 --- quote ---

 substr1([C|String], L) when L > 0 -> [C|substr1(String, L-1)];
 substr1(String, L) -> [].			%Be nice!

 --- end quote ---

 I rather like the "%Be nice!" comment.

 IMHO all the functions in string should exit when the "string" argument
is not a list - I'm not asking that you "deep check" the list but a little
help might be nice

 /Joe







More information about the erlang-questions mailing list