msz/hammox

FunctionClauseError with Ecto.Changeset.t()

nicholasjhenry opened this issue · 2 comments

A behaviour with a spec containing the type Ecto.Changeset.t() will raise a FunctionClauseError:

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

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

         # 1
         nil

         # 2
         {:var, 294, :data_type}

     Attempted function clauses (showing 10 out of 91):

         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)

     code: HammoxPlayground.Mock.perform(Decimal.new("0.992"))
     stacktrace:
       (hammox) lib/hammox/type_engine.ex:6: Hammox.TypeEngine.match_type/2
       (hammox) lib/hammox/type_engine.ex:372: anonymous fn/3 in Hammox.TypeEngine.match_type/2
       (elixir) lib/enum.ex:1340: anonymous fn/3 in Enum.map/2
       (stdlib) maps.erl:232: :maps.fold_1/3
       (elixir) lib/enum.ex:1964: Enum.map/2
       (hammox) lib/hammox/type_engine.ex:371: anonymous fn/2 in Hammox.TypeEngine.match_type/2
       (elixir) lib/enum.ex:3358: Enumerable.Map.reduce_list/3
       (elixir) lib/enum.ex:1998: Enum.reduce_while/3
       (hammox) lib/hammox/type_engine.ex:369: Hammox.TypeEngine.match_type/2
       (hammox) lib/hammox.ex:312: Hammox.match_return_value/2
       (hammox) lib/hammox.ex:280: Hammox.match_call/3
       (hammox) lib/hammox.ex:264: anonymous fn/4 in Hammox.check_call/3
       (elixir) lib/enum.ex:3325: Enumerable.List.reduce/3
       (elixir) lib/enum.ex:1998: Enum.reduce_while/3
       (hammox) lib/hammox.ex:263: Hammox.check_call/3
       (hammox) lib/hammox.ex:256: Hammox.protected_code/3
       test/hammox_playground_test.exs:13: (test)
msz commented

I can't reproduce this just by using a typespec containing Ecto.Changeset.t().

But I have a strong suspicion that #20 fixed this. Could you retest and confirm?

@msz Yes, it looks like #20 fixed that. Thank you for the recent fixes!