nimble_csv
nimble_csv copied to clipboard
Dialyzer error with NimbleCSV.RFC4180
I have an error with dialyzer, by using this dummy parse_stream, I'm obtaining no local return
defmodule MyMod
@spec base_stream(binary) :: Enumerable.t()
def base_stream(srcfile) do
srcfile
|> File.stream!([:read, :compressed, :utf8, read_ahead: 10_000])
|> NimbleCSV.RFC4180.parse_stream(skip_headers: false)
end
end
Finding suitable PLTs
Checking PLT...
...
PLT is up to date!
No :ignore_warnings opt specified in mix.exs and default does not exist.
Starting Dialyzer
[
check_plt: false,
init_plt: ~c"/app/_build/dev/dialyxir_erlang-26.0.2_elixir-1.15.4_deps-dev.plt",
files: [...],
warnings: [:unknown]
]
Total errors: 9, Skipped: 0, Unnecessary Skips: 0
done in 0m5.13s
...
________________________________________________________________________________
lib/tasks/image_captioning/prepare_image.ex:166:no_return
Function base_stream/1 has no local return.
________________________________________________________________________________
...
________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2
zsh returned exit code 2
My real codes is more or less:
defmodule Foo
def run(srcfile) do
[["1", "foo"]]
# srcfile
# |> base_stream()
|> Stream.map(fn [id, image_link] -> %{"id" => id, "image_link" => image_link} end)
|> ...
end
end
If I use the dummy example [["1", "foo"]] dialyzer doesn't fail, if I use it with the base_stream it fails. Any idea how to overcome this? I think it is a bug in RFC4180 parser definition
This project performs code generation and it may generate code that Dialyzer sees as dead code. We don't use dialyzer in this project, but a PR is welcome if you want to address the issue. Maybe adding quote generated: true do to some of the code generation will address it.