Closed Zabrane closed 2 months ago
Type-wise (wrt types and specs) the type error is correct.
Since
-type filter() :: {fun((log_event(),filter_arg()) -> filter_return()), filter_arg()}.
-type filter_arg() :: term().
See
The function fun logger_filters:domain/2
has the spec
-spec domain(LogEvent,Extra) -> logger:filter_return() when
LogEvent :: logger:log_event(),
Extra :: {Action,Compare,MatchDomain},
Action :: log | stop,
Compare :: super | sub | equal | not_equal | undefined,
MatchDomain :: list(atom()).
So, fun logger_filters:domain/2
is not a subtype of fun((log_event(),filter_arg()) -> filter_return())
which is expected.
(Note that sutyping of functions is contravariant in parameters)
FWIW I think that the type filter
should be defined as:
-type filter() :: {fun(log_event(), Arg) -> filter_return()), Arg}.
but AFAIK this is not supported by specs today
I think it could be supported if written directly as part of the spec (without the filter
alias).
Something like:
-spec add_handler_filter(HandlerId,FilterId,Filter) -> ok | {error,term()} when
HandlerId :: handler_id(),
FilterId :: filter_id(),
Filter :: {fun((log_event(), Arg) -> filter_return()), Arg}.
@ilya-klyuchnikov @michalmuskala Thanks for the feedback. What should I do to clear this error in my code then?
What should I do to clear this error in my code then?
You can use an ignore escape hatch in a comment. Something like.
% eqwalizer:ignore bad add_handler_filter spec
ok = logger:add_handler_filter(default, ftp_logger, Filter),
What should I do to clear this error in my code then?
You can use an ignore escape hatch in a comment. Something like.
% eqwalizer:ignore bad add_handler_filter spec ok = logger:add_handler_filter(default, ftp_logger, Filter),
@ilya-klyuchnikov it worked. Many thanks.
Hi guys
Eqwalizer is reporting an error which doesn't seem to be correct IMHO:
But according to the Erlang official doc, the call is legit:
My config:
Help appreciated. Many thanks