Quantcast
Viewing latest article 2
Browse Latest Browse All 2

Dialyzer: Unknown Type re:mp()

In this contrived example, the parsing module offers a function called parse_equation/2, which accepts an equation to be parsed, and a regular expression pattern to be used for said parsing:

-module(parsing).-export([parse_equation/2]).parse_equation(Equation, Pattern) ->    {match, [_, Left, Right]} = re:run(Equation, Pattern, [{capture, all, binary}]),    {Left, Right}.

This works as intended:

$ erl1> c(parsing).{ok,parsing}2> {ok, Pattern} = re:compile("^(.+) = (.+)$").{ok, ...}3> parsing:parse_equation("1 + 1 = 2", Pattern).{<<"1 + 1">>,<<"2">>}

I'd like to add a type specification to parse_equation/2. According to the re manpage,Pattern is of type mp(), i.e. re:mp() from my module. So this is my spec:

-spec parse_equation(string(), re:mp()) -> {binary(), binary()}.

However, the dialyzer cannot make sense of that specification:

$ dialyzer parsing.erl   Checking whether the PLT /home/patrick/.cache/erlang/.dialyzer_plt is up-to-date... yes  Proceeding with analysis...Unknown types:  re:mp/0 (/home/patrick/github.com/patrickbucher/learning-erlang/dialyzer-issue/parsing.erl:4:32) done in 0m0.14sdone (warnings were emitted)

How can I make the type re:mp() known to the dialyzer? I did run dialyzer --build_plt --apps erts kernel stdlib before.


Viewing latest article 2
Browse Latest Browse All 2

Trending Articles