-
Notifications
You must be signed in to change notification settings - Fork 35
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
Skip too complex guards #570
base: master
Are you sure you want to change the base?
Changes from all commits
f095cea
17e2770
0576b65
73e314f
ec5c19e
3f4fd6b
8117a02
701e244
8858c41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(type_refinement_should_fail). | ||
|
||
-export([pattern_prevents_refinement/2]). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we export all three functions? |
||
|
||
-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 | ||
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know that you just moved this function, but still, the comment can still be an integer seems a bit weird to me. The type |
||
|
||
-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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate adding the option (as it enables us to test Gradualizer's behaviour with/without it easily). I would also add the CLI option for it (to
src/gradualizer_cli.erl
and to theREADME.md
).