Skip to content

Commit

Permalink
failing testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoMin committed Sep 13, 2024
1 parent a71c3d7 commit af031a6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%% https://github.com/erlang-ls/erlang_ls/issues/1527
%% Only valid for OTP25 or higher
-module(diagnostics_bound_var_in_pattern_maybe).

-if(?OTP_RELEASE<27).
-feature(maybe_expr, enable).
-endif.

-export([foo/0]).

foo() ->
maybe
foo ?= bar()
else
e = Error -> Error
% ^- Bound variable in pattern: Error
end.

bar() ->
foo.
20 changes: 20 additions & 0 deletions apps/els_lsp/test/els_diagnostics_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
-export([
atom_typo/1,
bound_var_in_pattern/1,
bound_var_in_pattern_maybe/1,
bound_var_in_pattern_cannot_parse/1,
compiler/1,
compiler_with_behaviour/1,
Expand Down Expand Up @@ -193,6 +194,15 @@ init_per_testcase(TestCase, Config) when
->
mock_refactorerl(),
els_test_utils:init_per_testcase(TestCase, Config);
init_per_testcase(TestCase, Config) when
TestCase =:= bound_var_in_pattern_maybe
->
case ?OTP_RELEASE < 25 of
true ->
{skip, "Maybe expressions are only supported from OTP 25"};
false ->
Config
end;
init_per_testcase(TestCase, Config) ->
els_mock_diagnostics:setup(),
els_test_utils:init_per_testcase(TestCase, Config).
Expand Down Expand Up @@ -363,6 +373,16 @@ bound_var_in_pattern(_Config) ->
end,
els_test:run_diagnostics_test(Path, Source, Errors, Warnings, Hints).

%% #1527
-spec bound_var_in_pattern_maybe(config()) -> ok.
bound_var_in_pattern_maybe(_Config) ->
Path = src_path("diagnostics_bound_var_in_pattern_maybe.erl"),
Source = <<"BoundVarInPattern">>,
Errors = [],
Warnings = [],
Hints = [],
els_test:run_diagnostics_test(Path, Source, Errors, Warnings, Hints).

-spec bound_var_in_pattern_cannot_parse(config()) -> ok.
bound_var_in_pattern_cannot_parse(_Config) ->
Path = src_path("diagnostics_bound_var_in_pattern_cannot_parse.erl"),
Expand Down

0 comments on commit af031a6

Please sign in to comment.