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

Unable to run gradient on ExDoc #78

Closed
eksperimental opened this issue May 21, 2022 · 7 comments
Closed

Unable to run gradient on ExDoc #78

eksperimental opened this issue May 21, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@eksperimental
Copy link
Contributor

This is my branch based on ExDoc main, which only adds Gradient as a dependency:
https://github.com/eksperimental/ex_doc/tree/gradient

after mix do clean + deps.get
I run mix gradient and I get.

$ mix gradient
Loading deps...
Compiling project...
Typechecking files...
lib/ex_doc/autolink.ex: ** (ArgumentError) argument error
    :erlang.++([[[[[[[[[[[[[[[] | "\e[36m"], "("], "["], "]"], ","], " "], "nonempty_list"], "("], ")"], " ->"], " "], "false"], ")"] | "\e[0m"], [])
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/ex_doc/deps/gradualizer/src/gradualizer_fmt.erl:505: :gradualizer_fmt.pp_intersection_type/2
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/ex_doc/deps/gradualizer/src/gradualizer_fmt.erl:505: :gradualizer_fmt.pp_intersection_type/2
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/ex_doc/deps/gradualizer/src/gradualizer_fmt.erl:174: :gradualizer_fmt.format_type_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:208: Gradient.ElixirFmt.format_type_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:58: Gradient.ElixirFmt.print_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:44: anonymous fn/3 in Gradient.ElixirFmt.print_errors/2
    (elixir 1.13.4) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3

It looks like a Gradualizer issue, still reporting it here so you guys can elevate it accordingly if it is necessary.

@eksperimental
Copy link
Contributor Author

Same with Phoenix.

lib/phoenix/code_reloader/server.ex: ** (ArgumentError) argument error
    :erlang.++([[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[...], ...], "["], ""], "{"], ":atom"], ","], " "], "0"], ","], " "], ":is_subtype"], "}"], ","], " "], "["], ""], "{"], ":var"], ","], " "], "0"], ","], " "], ":MonitorRef"], "}"], ","], " "], "{"], ":type"], ","], " "], "0"], ","], " "], ":reference"], ","], " "], "["], "]"], "}"], ""], "]"], ""], "]"], "}"], "\n"], "]"], ""], ")"] | "\e[0m"], [])
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/phoenix/deps/gradualizer/src/gradualizer_fmt.erl:507: :gradualizer_fmt.pp_intersection_type/2
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/phoenix/deps/gradualizer/src/gradualizer_fmt.erl:507: :gradualizer_fmt.pp_intersection_type/2
    (gradualizer 0.1.3+build.1080.ref9e629ad) /home/user/git/phoenix/deps/gradualizer/src/gradualizer_fmt.erl:174: :gradualizer_fmt.format_type_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:208: Gradient.ElixirFmt.format_type_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:58: Gradient.ElixirFmt.print_error/2
    (gradient 0.1.0) lib/gradient/elixir_fmt.ex:44: anonymous fn/3 in Gradient.ElixirFmt.print_errors/2
    (elixir 1.13.4) lib/enum.ex:2396: Enum."-reduce/3-lists^foldl/2-0-"/3

@erszcz erszcz added the bug Something isn't working label May 24, 2022
@erszcz
Copy link
Member

erszcz commented May 24, 2022

I'm not sure what's wrong yet, but we certainly should not crash. Thanks for the report!

@Premwoik
Copy link
Collaborator

Premwoik commented May 24, 2022

@erszcz I can see this TODO in the Gradualizer code, so maybe this is a problem?

pp_intersection_type([], _) ->
    "";
%% TODO: pp_type seems to have problems printing bounded types.
pp_intersection_type([{type, _, bounded_fun, [Ty, []]} | Tys], Opts) ->
    pp_type(Ty, Opts) ++ ["\n" || Tys /= []] ++ pp_intersection_type(Tys, Opts);
pp_intersection_type([Ty|Tys], Opts) ->
    pp_type(Ty, Opts) ++ ["\n" || Tys /= []] ++ pp_intersection_type(Tys, Opts).

https://github.com/josefs/Gradualizer/blob/9e629ade733780113973fe672a51d9650ed0cd86/src/gradualizer_fmt.erl#L503-L507

@erszcz
Copy link
Member

erszcz commented May 24, 2022

@Premwoik Good catch, seems like the reason 👍

erszcz added a commit that referenced this issue May 24, 2022
Returning an improper list, as IO.ANSI.format() does,
leads to gradualizer_fmt crashing on the ++ operator.

See #78 for the original report.
@erszcz
Copy link
Member

erszcz commented May 24, 2022

Well, it turns out the TODO in Gradualizer is a false lead. The problem is that IO.ANSI.format() returns an improper list, which cannot be handled by ++. #79 fixes that, but it crashes on another issue.

@eksperimental eksperimental changed the title Unable to run gradient in ExDoc Unable to run gradient on ExDoc May 24, 2022
erszcz added a commit that referenced this issue May 25, 2022
Returning an improper list, as IO.ANSI.format() does,
leads to gradualizer_fmt crashing on the ++ operator.

See #78 for the original report.
@eksperimental
Copy link
Contributor Author

I think this one can be closed

@erszcz
Copy link
Member

erszcz commented May 30, 2022

@eksperimental Indeed, closing now as #79 is in 👍 Thanks again!

@erszcz erszcz closed this as completed May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants