-
Notifications
You must be signed in to change notification settings - Fork 35
Skip too complex guards #570
New issue
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f095cea
Add tests for (not) skipping complex guards
erszcz 17e2770
Skip checking functions with too complex guards
erszcz 0576b65
Refactor to avoid using an assertion
erszcz 73e314f
Add type_refinement_should_fail.erl, fix type_refinement_fail.erl
erszcz ec5c19e
Drop unnecessary assertions
erszcz 3f4fd6b
Run proptests on 25.1.2
erszcz 8117a02
Run proptests on 26.2.5
erszcz 701e244
Drop no_clause_has_guards condition when checking exhaustiveness
erszcz 8858c41
Handle all erl_anno:file() cases, fix self-check error
erszcz c63080a
Export all tests from type_refinement_should_fail, fix specs
erszcz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
test/known_problems/should_fail/type_refinement_should_fail.erl
This file contains hidden or 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,19 @@ | ||
-module(type_refinement_should_fail). | ||
|
||
-export([pattern_prevents_refinement/2]). | ||
erszcz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
-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(erlang:timestamp()) -> ok. | ||
guard_prevents_refinement2(X) when is_integer(X), X rem 7 == 0 -> ok; | ||
guard_prevents_refinement2(infinity) -> ok. % can still be an integer | ||
erszcz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
-spec pattern_prevents_refinement(erlang:timestamp(), 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.