-
Notifications
You must be signed in to change notification settings - Fork 424
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
Dyno: check return types when validating interface constraints #26471
Merged
DanilaFe
merged 12 commits into
chapel-lang:main
from
DanilaFe:dyno-interfaces-return-types
Jan 17, 2025
Merged
Dyno: check return types when validating interface constraints #26471
DanilaFe
merged 12 commits into
chapel-lang:main
from
DanilaFe:dyno-interfaces-return-types
Jan 17, 2025
Conversation
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
DanilaFe
force-pushed
the
dyno-interfaces-return-types
branch
2 times, most recently
from
January 8, 2025 00:51
9da542f
to
c8afd59
Compare
2 tasks
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
DanilaFe
force-pushed
the
dyno-interfaces-return-types
branch
from
January 15, 2025 01:36
c8afd59
to
8c41029
Compare
dlongnecke-cray
approved these changes
Jan 17, 2025
Signed-off-by: Danila Fedorin <[email protected]>
DanilaFe
added a commit
that referenced
this pull request
Jan 21, 2025
This PR adds support for context managers: ```Chapel manage bla as foo { // etc. } ``` It does so by leaning on interface support, since we have decided to use them to "bless" the special methods `enterContext` and `exitContext`. As such, this PR depends on #26396 and #26471. The diff without the interface implementations can be found here: https://github.com/chapel-lang/chapel/pull/26494/files/8c4102910462ff3e792bddaa75e01bdbf1b2ee63..a2e2745e3d47a65c284fb8119660288f028bbaa4 The general approach is straightforward: since we can compute witnesses for special interfaces like `contextManager`, this PR ensures that `manage` statements find the `contextManager` interface, and then use the witness functions as associated actions. Some complications arise due to the fact that context managers are design right now must be able to resolve return-intent-overloaded functions at `manage` time, which means (if the witness approach is to be used) that witnesses must contain all overloads. This PR adjusts for that, but only stores the additional overloads when `ifc any return intent` (the pragma that decorates `enterContext`) is used, thus attempting to avoid paying the multi-overload cost for other interfaces and functions. Reviewed by @riftEmber -- thanks! ## Testing - [x] dyno tests - [x] paratest
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.
Depends on #26396.
This PR implements return type checking for interfaces. To fit that nicely into the existing structure, it separates the main "find function that matches the given interface requirement" into pieces (building the call, picking a candidate, checking the formals, return type, and return intent). From there, it implements the rules as currently specified in
interfaceResolution
.The rules are as follows:
For types:
iter
procedures produce distinct return types.For intents:
ref
,const ref
, andparam
returns where values are expected (we can just dereference / construct a value).cons ref
, we allowref
, since we can always not modify the mutable reference.Reviewed by @dlongnecke-cray -- thanks!
Testing