[erlang-questions] Dialyzer
Carlo Bertoldi
carlo.bertoldi@REDACTED
Mon May 2 12:11:30 CEST 2011
On 02/05/2011 11:55, Kostis Sagonas wrote:
> Carlo Bertoldi wrote:
>> On 02/05/2011 11:23, Kostis Sagonas wrote:
>>> Carlo Bertoldi wrote:
>>>> Hello list,
>>>> this is a bad monday, and I'm stuck with this warning from dialyzer:
>>>>
>>>> The specification for change_interval/2 states that the function
>>>> might also return [any()] but the inferred return is none()
>>>>
>>>> The code:
>>>> -spec(change_interval(integer(), [term()]) -> [term()]).
>>>>
>>>> change_interval(NewInterval, Config) ->
>>>> NewPause = {pause, NewInterval},
>>>> NewConfig = lists:keyreplace(pause, 1, Config, NewPause),
>>>> write_config(NewPause),
>>>> NewConfig.
>>>>
>> I apologize for the incompleteness, here goes the module
>
> Well, probably it's a bad Monday alright for you. Wondering what
> exactly it is you did during the weekend... ;)
You don't wanna know ;)
>
> Anyway, didn't you happen to notice that dialyzer generates an awful
> lot of other warnings for this module?
Actually yes, but I thought about resolving the first issue of the list
before.
Of course I was awfully wrong, after fixing the call to file:open, all
the other warnings disappeared in a puff of logic.
This is a silly error indeed, but I wonder, how come that write_config
was working anyway?
I tested that before the weekend ;)
> Among them, a warning that basically tells you that the proper way to
> use file:open/2 is with a list of options in the second argument, i.e.
> file:open(File, [write]), instead of what you've written below?
> Please fix this.
>
> As to the warning you are getting, can't you see that the function
> change_interval/2 is nowhere used in this file? Even erlc will tell
> you that.
Sorry again, I didn't paste every lines of the actual module, and I've
read the mail a couple of times. Guess I do need a triple coffee.
Carlo
More information about the erlang-questions
mailing list