[erlang-bugs] Undetected undefined remote function calls

Ulf Wiger ulf@REDACTED
Mon Dec 17 12:42:45 CET 2012


Well, in the context of code loading, it is certainly possible, although more than a little weird. :)

The function sys:do_change_code/5 in OTP stdlib specifically relies on calling a function in the newly loaded version of a module, with data from the old version. It is of course calling a function that is well understood in advance, but this is only by convention, and not easily checkable*.

Let's say the presence of the exported function bar() indicates that a certain feature is supported, and the function looks like this:

test() ->
   case erlang:function_exported(foo, bar, 0) of
      true -> foo:bar();
      false -> ok
   end.

Should the compiler still warn?

(I'm open to the answer "yes". I don't think the above is a good solution).

BR,
Ulf W

* It's of course easy if both versions of the module are available for analysis, but they seldom are in practice.

On 17 Dec 2012, at 11:48, Kostis Sagonas wrote:

> Shouldn't the compiler be complaining that the module below contains an undefined function?  (*)
> 
> %%===================
> -module(foo).
> -export([test/0]).
> 
> test() ->
>  foo:bar().
> %%===================
> 
> Kostis
> 
> (*) Or is this treated as a call to a "future" version of the module? :P
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs

Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.
http://feuerlabs.com






More information about the erlang-bugs mailing list