Error "type counters_ref/0 undefined"

Hi!

I am using the :counters Erlang module and a spec like

@spec add_event(counters_ref()) :: :ok
def add_event(counters) do
  :counters.add(counters, @events_idx, 1)
end

Raises

type counters_ref/0 undefined (no such type in ...)

However, counters_ref/0 is an exported type.

Why isn’t the type known to the compiler?

Types are never imported, you have to fully qualify its name: :counter.counter_ref.

2 Likes

Ahhh, gotcha, thanks!

Now that I think, that is no different than String.t(). Guess I was kind of out of context reading the Erlang docs.