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 fails to suggest Specs for module - "Cannot extract typer info." #1343

Open
artman41 opened this issue Jun 22, 2022 · 1 comment
Open
Labels
bug Something isn't working

Comments

@artman41
Copy link

Describe the bug
When navigating through a project, some files consistently fail to suggest specs and suggest to view the log wherein I can see the following:

[2022-06-22T14:11:15.852490+01:00] [warning] Cannot extract typer info., Class: error, Exception: {case_clause,{error,invalid_contract}}, Stacktrace: [{els_typer,get_type,3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,244}]},{els_typer,'-get_types/3-lc$^1/1-0-',3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,229}]},{els_typer,'-get_types/3-lc$^1/1-0-',3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,229}]},{els_typer,get_types,3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,229}]},{els_typer,get_final_info,3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_typer.erl"},{line,207}]},{els_code_lens_suggest_spec,init,1,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_code_lens_suggest_spec.erl"},{line,29}]},{els_code_lens,lenses,2,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_code_lens.erl"},{line,91}]},{els_code_lens_provider,'-run_lenses_job/1-lc$^0/1-0-',3,[{file,"/__w/erlang_ls/erlang_ls/apps/els_lsp/src/els_code_lens_provider.erl"},{line,41}]}] [els_code_lens_suggest_spec:init/1 L39] <0.872.0>

To Reproduce
Unsure, the modules that this occur in don't appear special in any way. I can't provide the code as it's commercial, however I can test potential fixes.

Expected behavior
Specs to appear on the functions

Actual behavior
A lense appears above the functions stating Cannot extract specs (check logs for details)

Context

  • erlang_ls version (tag/sha): 274beb7
  • Editor used: VS Code
  • LSP client used: erlang-ls.erlang-ls-0.0.35
@artman41 artman41 added the bug Something isn't working label Jun 22, 2022
@artman41
Copy link
Author

artman41 commented Jun 22, 2022

Deleting the logs & reloading the window, I can see that the following errors appear to predate the warning.

[2022-06-22T14:24:22.596616+01:00] [error] Error while running dialyzer [type=throw] [error={dialyzer_error,"Analysis failed with error:\nCould not scan the following file(s):\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:113: can't find include file \"logger.hrl\"\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:644: undefined macro 'LOG_WARNING/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:889: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:388: function try_dispatch/4 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:631: function try_dispatch/4 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:633: function try_dispatch/4 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:861: function error_info/7 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/gen_server.erl:869: function error_info/7 undefined\n\nLast messages in the log cache:\n  Reading files and computing callgraph... "}] [els_dialyzer_diagnostics:run/1 L61] <0.368.0>
[2022-06-22T14:24:22.597285+01:00] [debug] Background job completed. [els_background_job:terminate/2 L205] <0.368.0>
[2022-06-22T14:24:22.596615+01:00] [error] Error while running dialyzer [type=throw] [error={dialyzer_error,"Analysis failed with error:\nCould not scan the following file(s):\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:38: can't find include file \"logger.hrl\"\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:357: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:582: undefined macro 'LOG_ERROR/3'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:701: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:736: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:763: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:838: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:942: undefined macro 'LOG_ERROR/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:1419: undefined macro 'LOG_INFO/2'\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:32: function handle_info/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:315: function start_children/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:368: function report_progress/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:372: function report_progress/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:434: function do_terminate/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:557: function restart/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:570: spec for undefined function handle_info/2\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:593: function terminate_dynamic_children/1 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:695: function do_restart/3 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:791: function start_children/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:822: function do_terminate/2 undefined\n/usr/local/lib/erlang/lib/stdlib-3.12/src/supervisor.erl:825: function do_terminate/2 undefined\n\nLast messages in the log cache:\n  Reading files and computing callgraph... "}] [els_dialyzer_diagnostics:run/1 L61] <0.168.0>
[2022-06-22T14:24:22.598026+01:00] [debug] Background job completed. [els_background_job:terminate/2 L205] <0.168.0>

I'm unsure if they're related but the problematic module is a gen_server

My erlang_ls.config looks like this

otp_path: "/usr/local/lib/erlang"
deps_dirs:
  - "lib/*"
  - "deps/*"
apps_dirs:
  - "."
  - "apps/*"
include_dirs:
  - "include"
  - "src"
  - "deps"
  - "_build/default/lib"
diagnostics:
  enabled:
    - bound_var_in_pattern
    - compiler
    - crossref
    - dialyzer
    - unused_includes
    - unused_macros
  disabled:
    - elvis
lenses:
  enabled:
    - ct-run-test
    - function-references
    - server-info
    - show-behaviour-usages
    - suggest-spec
plt_path: ".app.plt"

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

1 participant