-
Couldn't load subscription status.
- Fork 38
Description
We wanted to try eqwalizer on our elixir projects. I know it would be a lot better to implement a parser for Elixir projects, but as a first step we decompiled the beam files to erlang sources, and
we were running eqwalizer on those sources.
We have found some problems:
- in the decompiled source there is a
-fileattribute:
-file("lib/asdfqqqq.ex", 1).
-module('Elixir.Asdfqqqq').
When this attribute is there eqwalizer simply ignores all problems. If I manually delete this line, it works.
- there is also an info/1 function in the source:
'__info__'(module) -> 'Elixir.Asdfqqqq';
'__info__'(functions) -> [{double, 1}];
'__info__'(macros) -> [];
'__info__'(exports_md5) -> <<"\035S8}I7\030\232\236g-\023">>;
this last function clause will cause this problem:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 429, error_len: Some(1) }', crates/elp/src/bin/[reporting.rs:101](http://reporting.rs:101/):78
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
- actually, when I manually fix these problems eqwalizer works quite well, and it is able to spot the problems in the code (of course the line numbers are wrong). One remaining problem is that I could not figure out how to tell to eqwalizer where the declarations of Elixir types are. So for instance:
-spec double({error, 1}) -> 'Elixir.String':t().
double(_x@1) -> 2 * _x@1.
Elixir.String type is declared in $ELIXIR_DIR//lib/elixir/lib/string.ex. Similarly, I want to add all files where elixir types are declared. How can I add those using project.json?
I have one more question...
Let's say I have my_app application, which uses my_lib as a dependency. In my_app.erl I have the following:
-include_lib("my_lib/include/my_lib.hrl").
I've tried it with this project.json:
{
"apps": [
{
"name": "my_app",
"dir": "",
"ebin": "_build/default/lib/my_app/ebin",
"extra_src_dirs": [""],
"include_dirs": ["include"],
"macros": ["TEST"],
"src_dirs": ["src"]
}
],
"deps": [
{
"name": "my_lib",
"dir": "",
"ebin": "_build/default/lib/my_lib/ebin",
"extra_src_dirs": [""],
"include_dirs": ["_build/default/lib/my_lib/include"],
"macros": ["TEST"],
"src_dirs": ["src"]
}
],
"root": ""
}
elp is still complaining about being not able to find the include file:
eqWAlizing ████████████████████ 3/3 error: parse_error
┌─ src/my_app.erl:3:14
│
103 │ -include_lib("my_lib/include/my_lib.hrl").
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find include lib "my_lib/include/my_lib.hrl"
Do you have an idea what should I put into my project.json ?