diff --git a/apps/els_lsp/priv/code_navigation/src/diagnostics_bound_var_in_pattern_maybe.erl b/apps/els_lsp/priv/code_navigation/src/diagnostics_bound_var_in_pattern_maybe.erl index d6d87743..18db9b25 100644 --- a/apps/els_lsp/priv/code_navigation/src/diagnostics_bound_var_in_pattern_maybe.erl +++ b/apps/els_lsp/priv/code_navigation/src/diagnostics_bound_var_in_pattern_maybe.erl @@ -6,7 +6,7 @@ -feature(maybe_expr, enable). -endif. --export([foo/0]). +-export([foo/0, maybe_expr/0]). foo() -> maybe @@ -18,3 +18,12 @@ foo() -> bar() -> foo. + +maybe_expr() -> + X = 1, + Y = ok, + maybe + X ?= 1 + else + Y -> Y + end. diff --git a/apps/els_lsp/test/els_diagnostics_SUITE.erl b/apps/els_lsp/test/els_diagnostics_SUITE.erl index e718e2b3..38f9fc19 100644 --- a/apps/els_lsp/test/els_diagnostics_SUITE.erl +++ b/apps/els_lsp/test/els_diagnostics_SUITE.erl @@ -202,7 +202,9 @@ init_per_testcase(TestCase, Config) when {skip, "Maybe expressions are only supported from OTP 25"}; false -> Config - end; + end, + els_mock_diagnostics:setup(), + els_test_utils:init_per_testcase(TestCase, Config); init_per_testcase(TestCase, Config) -> els_mock_diagnostics:setup(), els_test_utils:init_per_testcase(TestCase, Config). @@ -380,7 +382,16 @@ bound_var_in_pattern_maybe(_Config) -> Source = <<"BoundVarInPattern">>, Errors = [], Warnings = [], - Hints = [], + Hints = [ + #{ + message => <<"Bound variable in pattern: X">>, + range => {{24, 9}, {24, 10}} + }, + #{ + message => <<"Bound variable in pattern: Y">>, + range => {{27, 9}, {27, 10}} + } + ], els_test:run_diagnostics_test(Path, Source, Errors, Warnings, Hints). -spec bound_var_in_pattern_cannot_parse(config()) -> ok.