Skip to content

Support erlang records #80

@ulissesalmeida

Description

@ulissesalmeida

Some Elixir libraries have references to erlang types, like Erlang records.

For example, the OpenTelemetry library has start_opts type:

https://hexdocs.pm/opentelemetry_api/OpenTelemetry.Tracer.html#t:start_opts/0

If you try to reference it and use Hammox protect, it raises an exception like this:

    The following arguments were given to Hammox.TypeEngine.match_type/2:
         # 1
         {:some_attribute, "somevallue"}
         # 2
         {:type, 116, :record, [{:atom, 116, :link}]}
     Attempted function clauses (showing 10 out of 92):
         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)

It would be very cool if Hammox could verify it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions