-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #570 from erszcz/skip-too-complex-guards
Skip too complex guards
- Loading branch information
Showing
8 changed files
with
139 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
test/known_problems/should_fail/type_refinement_should_fail.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-module(type_refinement_should_fail). | ||
|
||
-export([guard_prevents_refinement/2, | ||
guard_prevents_refinement2/1, | ||
pattern_prevents_refinement/2]). | ||
|
||
-spec guard_prevents_refinement(1..2, boolean()) -> 2. | ||
guard_prevents_refinement(N, Guard) -> | ||
case N of | ||
1 when Guard -> 2; | ||
M -> M %% 1 cannot be eliminated | ||
end. | ||
|
||
-spec guard_prevents_refinement2(integer()) -> ok. | ||
guard_prevents_refinement2(X) when is_integer(X), X rem 7 == 0 -> ok; | ||
guard_prevents_refinement2(X) -> ok. % X can still be an integer | ||
|
||
-spec pattern_prevents_refinement(integer(), any()) -> atom(). | ||
pattern_prevents_refinement(X, X) when is_integer(X) -> ok; | ||
pattern_prevents_refinement(X, {_Y}) when is_integer(X) -> ok; | ||
pattern_prevents_refinement(Inf, _) -> Inf. % Inf can still be an integer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters