jeremyjh / dialyxir

Mix tasks to simplify use of Dialyzer in Elixir projects.
Apache License 2.0
1.69k stars 141 forks source link

Failed to parse warning #438

Open parry84 opened 3 years ago

parry84 commented 3 years ago

Failed to parse warning: [{:"{", 1}, {:atom_full, 1, '\'ok\''}, {:",", 1}, {:"#", 1}, {:"{", 1}, {:atom_full, 1, '\'__typename\''}, {:":=", 1}, {:<, 1}, {:<, 1}, {:int, 1, 384677985324449735536498}, {:":", 1}, {:int, 1, 80}, {:>, 1}, {:>, 1}, {:",", 1}, {:atom_full, 1, '\'error\''}, {:":=", 1}, {:<, 1}, {:<, 1}, {:int, 1, 2037172997037120384612}, {:":", 1}, {:int, 1, 72}, {:>, 1}, {:>, 1}, {:"}", 1}, {:"}", 1}]

Legacy warning: service.ex:0: The pattern {'ok', #{'__typename':=<<384677985324449735536498:80>>, 'error':=<<2037172997037120384612:72>>}} can never match the type {'ok',#{'installment_prices':=[]}}


Snippet to reproduce:

    {:ok, %{installment_prices: []}}
    |> case do
      {:ok, %{__typename: "Error", error: "not_found"}} ->
        {:error, :not_found}

      {:ok, %{installment_prices: installment_prices}} ->
        {:ok, Helpers.GraphQLUtils.format_response(installment_prices)}
JonRowe commented 2 years ago

I think I have another example of this, dialyzer asked me nicely to open an issue but as I think this is a duplicate I'll add it here:

Failed to parse warning:
[{:<, 1}, {:<, 1}, {:<, 1}, {:int, 1, 36343226021761516267932838254}, {:":", 1}, {:int, 1, 96}, {:>, 1}, {:>, 1}, {:",", 1}, {:_, 1}, {:atom_part, 1, 'v'}, {:atom_part, 1, 'a'}, {:atom_part, 1, 'l'}, {:atom_part, 1, 'u'}, {:atom_part, 1, 'e'}, {:atom_part, 1, '@'}, {:int, 1, 1}, {:",", 1}, {:"#", 1}, {:"{", 1}, {:atom_full, 1, '\'county_code\''}, {:":=", 1}, {:_, 1}, {:atom_part, 1, 'c'}, {:atom_part, 1, 'o'}, {:atom_part, 1, 'u'}, {:atom_part, 1, 'n'}, {:atom_part, 1, 't'}, {:atom_part, 1, 'r'}, {:atom_part, 1, 'y'}, {:_, 1}, {:atom_part, 1, 'c'}, {:atom_part, 1, 'o'}, {:atom_part, 1, 'd'}, {:atom_part, 1, 'e'}, {:atom_part, 1, '@'}, {:int, 1, 1}, {:",", 1}, {:atom_full, 1, '\'ein\''}, {:":=", 1}, {:_, 1}, {:atom_part, 1, 'e'}, {:atom_part, 1, 'i'}, {:atom_part, 1, 'n'}, {:atom_part, 1, '@'}, {:int, 1, 1}, {:"}", 1}, {:>, 1}]

The underlying error was actually a typo in the map field matching against a struct