Add is overload for free function predicate#669
Closed
filipsajdak wants to merge 3 commits intohsutter:mainfrom
Closed
Add is overload for free function predicate#669filipsajdak wants to merge 3 commits intohsutter:mainfrom
is overload for free function predicate#669filipsajdak wants to merge 3 commits intohsutter:mainfrom
Conversation
JohelEGP
reviewed
Sep 9, 2023
54f10df to
ec413e8
Compare
Current implementation of `is` does not handle generic functions as predicates.
The following case works:
```cpp
less_than_10_a: (i : int) -> bool = i < 10;
main: () = {
12 is (less_than_10_a);
}
```
It work also when function has generic return type
```cpp
less_than_10_b: (i : int) -> _ = i < 10;
main: () = {
12 is (less_than_10_b);
}
```
It does not work when function has generic argument.
The following case does not work:
```cpp
less_than_10_c: (i) -> _ = i < 10;
main: () = {
12 is (less_than_10_c); // error
}
```
This change introduce additional overload for `is` making free function
predicates acceptable by `is` (the function needs to return
`bool` or generic type). That makes the following cases to work:
```cpp
less_than_10_c: (i) -> _ = i < 10;
less_than_10_d: (i) -> bool = i < 10;
main: () = {
5 is (less_than_10_c); // works
2 is (less_than_10_d); // works
}
```
Functions that return other type then `bool` or `auto` do not work.
ec413e8 to
6ca5444
Compare
Contributor
Author
|
I am closing this one as it is covered by #701 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The current implementation of
isdoes not handle generic functions as predicates.The following case works:
It works also when the function has a generic return type:
But, it does not work when the function has a generic argument. The following case does not work:
This change introduces additional overload for
is, making the free function predicates acceptable byis(the function needs to returnboolor generic type). That makes the following cases work:Functions that return other types than
boolorautodo not work.All regression tests pass. Add a test for this case and update the regression test results.