warn_unused_vars

James Hague <>
Wed Feb 5 19:03:47 CET 2003


>> get_creds(Users, App) ->
>>      [ get_cred(User, App) || User <- Users ].
>
>That was a bug in the linter, but it has been fixed, at
>least in R9.

On a related note, you get a bizarre runtime error and no compile time
warnings if you don't bind a variable on the right side of a list
comprenshion.  For example, take the standard definition of map:

map(F, [H|T]) ->
    [F(H)|map(F, T)];
map(_, []) -> [].

and change it to:

map(F, [H|T]) ->
    [F(H)||map(F, T)];
map(_, []) -> [].

I did this by accident once, and it took me half an hour to see the typo.
You get an error report indicating that a case expression couldn't be
matched, but I would think this code shouldn't get through the compiler in
the first place.  Or is there a reason to allow list comprehensions with a
single predicate on the right side?

James



More information about the erlang-questions mailing list