hammox icon indicating copy to clipboard operation
hammox copied to clipboard

Bug with Hammox when upgrading Elixir

Open epinault opened this issue 1 year ago • 3 comments

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)

epinault avatar Jun 03 '24 18:06 epinault

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 avatar Aug 27 '24 12:08 kerryb

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.

kerryb avatar Aug 27 '24 12:08 kerryb

@msz are you willing to get more help? We are getting stuck to the point of needing to fork and was hoping we would not have to. Would you be open to have more maintainer to give this library away?

epinault avatar May 21 '25 22:05 epinault

@epinault, did you end up making a fork?

apreifsteck-luna avatar Jul 08 '25 13:07 apreifsteck-luna

Sorry been pretty busy in my end but planning to work on it next week

epinault avatar Jul 08 '25 17:07 epinault

Also I am in touch with the maintainer to get more access hopefully by next week

epinault avatar Jul 08 '25 17:07 epinault

Fixed in https://github.com/msz/hammox/releases/tag/v0.7.1. Sorry for the wait!

msz avatar Jul 26 '25 23:07 msz