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

Dialyzer failing on Tesla (master) #642

Open
nathany-copia opened this issue Dec 27, 2023 · 3 comments · May be fixed by #643
Open

Dialyzer failing on Tesla (master) #642

nathany-copia opened this issue Dec 27, 2023 · 3 comments · May be fixed by #643

Comments

@nathany-copia
Copy link

Just cloned Tesla (commit 6388e3c) and ran mix dialyzer on Elixir 1.16.0.

The following output:

Finding suitable PLTs
Checking PLT...
Dialyxir has deprecated plt_add_deps: :project in favor of apps_direct, which includes only runtime dependencies.
** (ArgumentError) errors were found at the given arguments:

  * 2nd argument: not a tuple

    (erts 14.2.1) :erlang.element(1, :mime)
    (dialyxir 1.4.2) lib/dialyxir/project.ex:371: anonymous fn/1 in Dialyxir.Project.load_project_deps/1
    (elixir 1.16.0) lib/enum.ex:1700: Enum."-map/2-lists^map/1-1-"/2
    (elixir 1.16.0) lib/map.ex:262: Map.new_from_enum/2
    (dialyxir 1.4.2) lib/dialyxir/project.ex:371: Dialyxir.Project.load_project_deps/1
    (dialyxir 1.4.2) lib/dialyxir/project.ex:342: anonymous fn/2 in Dialyxir.Project.include_deps/0
    (dialyxir 1.4.2) lib/dialyxir/project.ex:321: Dialyxir.Project.include_deps/0
    (dialyxir 1.4.2) lib/dialyxir/project.ex:53: Dialyxir.Project.cons_apps/0
@nathany-copia nathany-copia changed the title Dialyzer failing on Tesla (main) Dialyzer failing on Tesla (master) Dec 27, 2023
@yordis
Copy link
Member

yordis commented Dec 27, 2023

@nathany-copia are you able to fix the situation yourself?

@nathany-copia
Copy link
Author

I can try.

Is apps_direct the right option? Default is app_tree.

https://github.com/jeremyjh/dialyxir?tab=readme-ov-file#dependencies

Then it gets interesting -- I'll see if I can figure these out, but I do find dialyzer errors rather difficult to read.

lib/tesla/multipart.ex:94: Function add_file/2 has no local return
lib/tesla/multipart.ex:94: Function add_file/3 has no local return
lib/tesla/multipart.ex:106: The call 'Elixir.File':'stream!'(_path@1::binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | char(),binary() | []),[],2048) breaks the contract ('Elixir.Path':t(),'line' | pos_integer(),[stream_mode()]) -> 'Elixir.File.Stream':t()

@nathany-copia
Copy link
Author

nathany-copia commented Dec 27, 2023

Elixir 1.16.0 deprecated File.stream!(file, options, line_or_bytes)

So this line File.stream!(path, [], 2048) should just be File.stream!(path, 2048). I've had to make the same change in my own code to resolve a similar Dialyzer error.

I'm not sure exactly how to do that while still supporting Elixir < 1.16.0 though. 🤔

FYI, the reason why I'm here trying this is because code that uses Tesla is seeing similar Dialyzer errors bubble up through the call stack in Elixir 1.16.

nathany-copia added a commit to copia-wealth-studios/tesla that referenced this issue Dec 27, 2023
@nathany-copia nathany-copia linked a pull request Dec 27, 2023 that will close this issue
nathany-copia added a commit to copia-wealth-studios/tesla that referenced this issue Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants