We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug Using a record field as index doesn't count towards marking it as "used".
To Reproduce Write the following record definition and function:
-record(used_field, {field_c}). main(R) -> element(#used_field.field_c, R).
Expected behavior No warnings.
Actual behavior One warning: "Unused record field: #used_field.field_c"
Context
erlang_ls
The following change cause the unused_record_fields test from els_diagnostics_SUITE to fail, even though it shouldn't:
unused_record_fields
els_diagnostics_SUITE
diff --git a/apps/els_lsp/priv/code_navigation/src/diagnostics_unused_record_fields.erl b/apps/els_lsp/priv/code_navigation/src/diagnostics_unused_record_fields.erl index f10efc7..5ddfacd 100644 --- a/apps/els_lsp/priv/code_navigation/src/diagnostics_unused_record_fields.erl +++ b/apps/els_lsp/priv/code_navigation/src/diagnostics_unused_record_fields.erl @@ -8,4 +8,4 @@ main(#used_field{field_a = A, field_b = B}) -> {A, B}; main(R) -> - R#unused_field.field_c. + element(#unused_field.field_c, R).
Not knowing anything about the internals of erlang_ls (yet?) I've the tried the following without any effect:
diff --git a/apps/els_lsp/src/els_unused_record_fields_diagnostics.erl b/apps/els_lsp/src/els_unused_record_fields_diagnostics.erl index 4e92e46..7b2e0e3 100644 --- a/apps/els_lsp/src/els_unused_record_fields_diagnostics.erl +++ b/apps/els_lsp/src/els_unused_record_fields_diagnostics.erl @@ -55,7 +55,7 @@ source() -> -spec find_unused_record_fields(els_dt_document:item()) -> [els_poi:poi()]. find_unused_record_fields(Document) -> Definitions = els_dt_document:pois(Document, [record_def_field]), - Usages = els_dt_document:pois(Document, [record_field]), + Usages = els_dt_document:pois(Document, [record_field, record_index]), UsagesIds = lists:usort([Id || #{id := Id} <- Usages]), [POI || #{id := Id} = POI <- Definitions, not lists:member(Id, UsagesIds)].
The text was updated successfully, but these errors were encountered:
[erlang-ls#1391] Add support for record index in els_parser
a752dba
[#1391] Add support for record index in els_parser (#1392)
c6a8a5e
* [#1391] Add support for record index in els_parser * Fix typo in test suite
Successfully merging a pull request may close this issue.
Describe the bug
Using a record field as index doesn't count towards marking it as "used".
To Reproduce
Write the following record definition and function:
Expected behavior
No warnings.
Actual behavior
One warning: "Unused record field: #used_field.field_c"
Context
erlang_ls
version (tag/sha): 0.44.1/b151f9d9a4a1dde1118ae2822226500e2fa69125The following change cause the
unused_record_fields
test fromels_diagnostics_SUITE
to fail, even though it shouldn't:Not knowing anything about the internals of
erlang_ls
(yet?) I've the tried the following without any effect:The text was updated successfully, but these errors were encountered: