Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore binwrite error response handling warning #951

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

luismiramirez
Copy link
Member

@luismiramirez luismiramirez commented Jun 21, 2024

IO's module binwrite/2 function no longer returns an error touple when
failing. Instead, it raises an Erlang error. This commit makes dialyzer
ignore that warning so it behaves appropriately in newer and older
versions.

[skip changeset]

Ref: https://github.com/elixir-lang/elixir/blob/v1.17.1/lib/elixir/lib/io.ex#L280-L284

@tombruijn
Copy link
Member

Sounds like this would break in real apps, wouldn't we want to ship a new version with this?

@luismiramirez
Copy link
Member Author

Sounds like this would break in real apps, wouldn't we want to ship a new version with this?

I'm not too confident with the change because of this, either. In older lang versions wouldn't be a huge break but a silent crash, probably.

What do you think if we avoid Dialyzer checking that line? At the end of the day, it's only an unmatchable pattern warning.

@tombruijn
Copy link
Member

If it can never be anything else than an :ok, we can just as well write it like:

:ok = IO.binwrite(file, appsignal_config_file_contents(config))
IO.puts("Success!")

If it raises an error, it would become something like:

try do
  :ok = IO.binwrite(file, appsignal_config_file_contents(config))
  IO.puts("Success!")
rescue
  e -> e
    IO.puts("Failure! #{inspect(e)}")
    exit(:shutdown)
end

@luismiramirez
Copy link
Member Author

It might be an error tuple on older versions. That's why maybe it's more sensible to skip the linter.

@luismiramirez luismiramirez force-pushed the fix-impossible-pattern branch 2 times, most recently from aa81d6f to 932f7c6 Compare June 21, 2024 13:52
@luismiramirez luismiramirez changed the title Fix binwrite error response handling Ignore binwrite error response handling warning Jun 21, 2024
IO's module `binwrite/2` function no longer returns an error touple when
failing. Instead, it raises an Erlang error. This commit makes dialyzer
ignore that warning so it behaves appropriately in newer and older
versions.

[skip changeset]
@backlog-helper
Copy link


This is a message from the daily scheduled checks.

New issue guide | Backlog management | Rules | Feedback

@luismiramirez luismiramirez merged commit 89dda86 into main Jun 25, 2024
17 checks passed
@luismiramirez luismiramirez deleted the fix-impossible-pattern branch June 25, 2024 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants