Dialyzer reports no_return on Ecto.Enum.values

Since Ecto 3.7 Dialyzer reports no_return errors on the following line.

Ecto.Enum.values(EctoEnum.Schema, :my_enum)

Dialyzer error:

lib/ecto_enum.ex:0:no_return
Function enum_values/0 has no local return.

I’m not sure if I’m doing something wrong here or if this is a bug with Ecto 3.7. It also does the same with mappings and dump_values.

2 Likes

The functions in the Ecto.Enum module are annotated as taking Ecto.Schema.t type as first argument which is a map, but in implementation they call schema.__changeset__() which indicates that the schema should be a module. Fixing the specs to say module instead should resolve your issues.

6 Likes

You can send a PR to Ecto to see what the Ecto team thinks, or I can do that in the next few days.

Yes that’s it! I just kept looking over it, thanks for pointing it out.

I opened a PR.

1 Like