Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with Hammox when upgrading Elixir #146

Open
epinault opened this issue Jun 3, 2024 · 2 comments
Open

Bug with Hammox when upgrading Elixir #146

epinault opened this issue Jun 3, 2024 · 2 comments

Comments

@epinault
Copy link

epinault commented Jun 3, 2024

Hello,

I am upgrading from elixir 1.15 to 1.16.3, OTP version is the same 26.2.5

yet test that were passing in 1.15 are now failing with this error.

any idea what the issue might be?

** (FunctionClauseError) no function clause matching in Hammox.TypeEngine.match_type/2

 The following arguments were given to Hammox.TypeEngine.match_type/2:

     # 1
     %{}

     # 2
     {:type, {87, 25}, :record, [{:atom, {87, 26}, :set}, {:type, {87, 30}, :field_type, [{:atom, {87, 30}, :segs}, {:remote_type, 0, [{:atom, 0, :sets}, {:atom, 0, :segs}, [{:type, {57, 16}, :term, []}]]}]}]}

 Attempted function clauses (showing 10 out of 93):

     def match_type(value, {:type, _, :union, union_types} = union) when is_list(union_types)
     def match_type(_value, {:type, _, :any, []})
     def match_type(value, {:type, _, :none, []} = type)
     def match_type(value, {:type, _, :atom, []}) when is_atom(value)
     def match_type(value, {:type, _, :atom, []} = type)
     def match_type(value, {:type, _, :map, :any}) when is_map(value)
     def match_type(value, {:type, _, :pid, []}) when is_pid(value)
     def match_type(value, {:type, _, :pid, []} = type)
     def match_type(value, {:type, _, :port, []}) when is_port(value)
     def match_type(value, {:type, _, :port, []} = type)
     ...
     (83 clauses not shown)
@kerryb
Copy link

kerryb commented Aug 27, 2024

I’m getting pretty much the same error (Hammox 0.7.0, Erlang 27.0, Elixir 1.17.2-otp-27). I’m trying to retrofit Hammox to a project that currently uses Mox, so I don’t know whether it would have passed on older versions.

     ** (FunctionClauseError) no function clause matching in Hammox.TypeEngine.match_type/2

     The following arguments were given to Hammox.TypeEngine.match_type/2:

         # 1
         %{}

         # 2
         {:type, {163, 25}, :record, [{:atom, {163, 26}, :set}, {:type, {163, 30}, :field_type, [{:atom, {163, 30}, :segs}, {:remote_type, 0, [{:atom, 0, :sets}, {:atom, 0, :segs}, [{:remote_type, {62, 46}, [{:atom, 0, String}, {:atom, 0, :t}, []]}]]}]}]}

     Attempted function clauses (showing 10 out of 93):

         def match_type(value, {:type, _, :union, union_types} = union) when is_list(union_types)
         def match_type(_value, {:type, _, :any, []})
         def match_type(value, {:type, _, :none, []} = type)
         def match_type(value, {:type, _, :atom, []}) when is_atom(value)
         def match_type(value, {:type, _, :atom, []} = type)
         def match_type(value, {:type, _, :map, :any}) when is_map(value)
         def match_type(value, {:type, _, :pid, []}) when is_pid(value)
         def match_type(value, {:type, _, :pid, []} = type)
         def match_type(value, {:type, _, :port, []}) when is_port(value)
         def match_type(value, {:type, _, :port, []} = type)
         ...
         (83 clauses not shown)

It looks like Hammox is trying to check a record type, which it doesn’t support. I think this may be an issue with typespecs that use MapSet.t(), as MapSet is built on top of Erlang’s :sets, which in turn are defined as records.

@kerryb
Copy link

kerryb commented Aug 27, 2024

I’ve added a specific issue for MapSet support (I don’t know how big an enhancement it would be). I’m not sure that’s exactly the same problem you have, but hopefully it’ll help narrow things down slightly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants