From 9ceb0df48b624c90faaeb5038d95052b5874d56e Mon Sep 17 00:00:00 2001 From: Roberto Aloi Date: Wed, 4 Sep 2024 00:38:50 -0700 Subject: [PATCH] Add testcase to showcase unused record field false positive Summary: The test case highlights the fact we don't expand macros when looking for record fields (among other things), as originally reported [here](https://github.com/WhatsApp/erlang-language-platform/issues/51). This will be fixed later in the stack. Reviewed By: michalmuskala, alanz Differential Revision: D62128559 fbshipit-source-id: 43e9fa57b534ecbbb9357d12f91085a37b008993 --- crates/ide/src/diagnostics/unused_record_field.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ide/src/diagnostics/unused_record_field.rs b/crates/ide/src/diagnostics/unused_record_field.rs index fe108a417a..76fddb5cc9 100644 --- a/crates/ide/src/diagnostics/unused_record_field.rs +++ b/crates/ide/src/diagnostics/unused_record_field.rs @@ -149,4 +149,18 @@ main(#a{a1 = #b{b2 = B2}} = A) -> "#, ); } + + #[test] + fn test_unused_record_macro_name() { + // https://github.com/WhatsApp/erlang-language-platform/issues/51 + check_diagnostics( + r#" +-module(main). +-export([ test/0 ]). +-record(?MODULE, {queue :: term()}). + %% ^^^^^^^^^^^^^^^ warning: Unused record field ([missing name].queue) +test() -> #?MODULE{queue = ok}. + "#, + ); + } }