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 when struct is to match a string. #450

Open eksperimental opened 2 years ago

eksperimental commented 2 years ago

Precheck

Environment

Current behavior

Please file a bug in https://github.com/jeremyjh/dialyxir/issues with this message.

Failed to parse warning:
[{:<, 1}, {:<, 1}, {:int, 1, 211228306992}, {:":", 1}, {:int, 1, 40}, {:>, 1}, {:>, 1}]

Legacy warning:
lib/beam_meta/util.ex:65: The pattern <<211228306992:40>> can never match the type #{'__struct__':='Elixir.Version', _=>_}

the simplified code is

  def to_version_requirement(%Version{} = version) do
    case version do
      "1.0.0" -> "1.0.0"
      _ -> "-0"
    end
  end

the offending lines is "1.0.0" -> "1.0.0" because version is a struct, so i can never match that string.