[erlang-bugs] Undetected undefined remote function calls

Ulf Wiger ulf@REDACTED
Tue Dec 18 17:18:38 CET 2012


Well, the compiler cannot make a determination about an inter-module function call in the general case, so this particular case would be the only one it could warn about. Is it really worth the effort?

Dialyzer, on the other hand, will warn about unresolved external calls, and should definitely warn about this one. So should xref.

BR,
Ulf W

On 18 Dec 2012, at 16:58, Loïc Hoguin wrote:

> All true, but warnings are there to inform the developer that what he's doing is probably wrong. Not all warnings are caused by actual errors (like not using a defined variable). Doing foo:bar() from foo has very little chances of being done on purpose if bar isn't defined. Setting a warning for this does make sense.
> 
> Of course as with all other warnings you should be able to disable it if you actually need to do something like this.
> 
> On 12/18/2012 04:48 PM, Robert Virding wrote:
>> To clarify myself:
>> 
>> Calling foo:bar() is doing an intermodule call in which case detecting whether the function exists or not is left to run-time and it is irrelevant which module it is.
>> 
>> Robert
>> 
>> ----- Original Message -----
>>> From: "Robert Virding" <robert.virding@REDACTED>
>>> To: "Kostis Sagonas" <kostis@REDACTED>
>>> Cc: "erlang-bugs" <erlang-bugs@REDACTED>
>>> Sent: Tuesday, 18 December, 2012 4:21:16 PM
>>> Subject: Re: [erlang-bugs] Undetected undefined remote function calls
>>> 
>>> Not really. You are making a fully qualified "external" call to a
>>> function in another module, which in this case happens to be the
>>> same module, and the function's existence is checked at run-time.
>>> Even if the function existed when you make the call you would not
>>> make an internal jump but go through the modules exported function
>>> table. Calling function foo/1 in the same module behaves differently
>>> if you call it foo(5) or if you call it module:foo(5). So in that
>>> sense it does make perfect sense to NOT complain about an undefined
>>> function.
>>> 
>>> It is similar to the difference in doing exit(boom) and exist(self(),
>>> boom).
>>> 
>>> Robert
>>> 
>>> ----- Original Message -----
>>>> From: "Kostis Sagonas" <kostis@REDACTED>
>>>> To: "erlang-bugs" <erlang-bugs@REDACTED>
>>>> Sent: Monday, 17 December, 2012 11:48:58 AM
>>>> Subject: [erlang-bugs] Undetected undefined remote function calls
>>>> 
>>>> 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
>>>> 
>>> _______________________________________________
>>> erlang-bugs mailing list
>>> erlang-bugs@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-bugs
>>> 
>> _______________________________________________
>> erlang-bugs mailing list
>> erlang-bugs@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-bugs
>> 
> 
> 
> -- 
> Loïc Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
> _______________________________________________
> 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