dashbitco / dashbitco/nimble_csv

Dialyzer error with NimbleCSV.RFC4180

Open
#79 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
823
Forks
60
Avg merge
1d 22m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the MyMod.base_stream/1 example and inspect the type information for NimbleCSV.RFC4180.parse_stream/1, especially its interaction with File.stream!/2 and Enumerable.t(). Compare the inferred return with the declared spec and add or update the relevant test so Dialyzer no longer reports no_return for this usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.