Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mhanberg/with_dialyzer
https://github.com/mhanberg/with_dialyzer
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mhanberg/with_dialyzer
- Owner: mhanberg
- Created: 2024-02-14T17:31:05.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-02-14T17:36:31.000Z (9 months ago)
- Last Synced: 2024-05-01T13:52:30.186Z (7 months ago)
- Language: Elixir
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WithDialyzer
Demo of a dialyzer warning that I believe is caused by a new way of compiling the `with` special form into Erlang
Using the versions
```
erlang = "26.2.2"
elixir = "ref:52eaf1456182d5d6cce22a4f5c3f6ec9f4dcbfd9"
```This case I believe is somewhat interesting because according to the erlang docs, the `:inet.gethostname/0` function "never fails".
```elixir
with {:ok, host} <- :inet.gethostname() do
host
end
``````
lib/with_dialyzer.ex:3:pattern_match_cov
The pattern
variable_can never match, because previous clauses completely cover the type
{:ok, [byte()]}.
```However, if you switch this from the left stab operator to the match operator, it passes
```elixir
with {:ok, host} = :inet.gethostname() do
host
end
```This case was reduced from the application code
```elixir
with {:ok, host} <- :inet.gethostname(),
node = :"#{sname}@#{host}",
true <- connect(node, port, 120) do
NextLS.Logger.info(logger, "Connected to node #{node}"):next_ls
|> :code.priv_dir()
|> Path.join("monkey/_next_ls_private_compiler.ex")
|> then(&:rpc.call(node, Code, :compile_file, [&1]))
|> tap(fn
{:badrpc, error} ->
NextLS.Logger.error(logger, "Bad RPC call to node #{node}: #{inspect(error)}")
send(me, {:cancel, error})_ ->
:ok
end)send(me, {:node, node})
else
error ->
send(me, {:cancel, error})
end
```