Dialyzer treats atoms like `errors_400` in unexpected way: bug or my misunderstanding?

I want dialyzer to validate allowed map keys to replace record with map, but maintain integrity of used keys.

Everything works ok, unless I add keys like errors_400 to allowed options. After adding, dialyzer allows to add any key without any warning.

This is the issue: Dialyzer fails to report error when atom in options has digits and underscore · Issue #8808 · erlang/otp · GitHub

Is it a bug, or I miss something?

I want dialyzer to raise warning like:

a.erl:33:2: Invalid type specification for function a:stats/1.
 The success typing is a:stats
          (#decoder{}) ->
             {'ok', #{'reset_count' := _}, #decoder{reset_count :: 0}}
 But the spec is a:stats
          (#decoder{}) -> {'ok', metrics_map(), #decoder{}}
 The return types do not overlap

thanks to John Högberg. I have removed extra complexity and put all keys into map type declaration, now it works.

1 Like