Dyno: Iterate over param enum ranges#27586
Merged
DanilaFe merged 6 commits intochapel-lang:mainfrom Aug 5, 2025
Merged
Conversation
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
fe73c46 to
4daf0af
Compare
benharsh
reviewed
Aug 4, 2025
frontend/lib/resolution/Resolver.cpp
Outdated
| }; | ||
|
|
||
| template <typename R> | ||
| static bool populateParamRangeInfoFromBound(R& scratch, optional<typename R::Iter> low, optional<typename R::Iter> hi, Range::OpKind opKind, int step, int numElts) { |
Member
There was a problem hiding this comment.
Could/should these two "populate" functions be part of a factory method on one of these structs?
frontend/lib/resolution/Resolver.cpp
Outdated
| auto enumType = yieldType->toEnumType(); | ||
| auto enumDecl = parsing::idToAst(context, enumType->id())->toEnum(); | ||
| CHPL_ASSERT(enumDecl); | ||
| auto info = toOwned(new EnumParamRangeInfo(enumDecl->enumElements())); |
Member
There was a problem hiding this comment.
Would the logic in this branch be better placed in a factory method?
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
benharsh
approved these changes
Aug 5, 2025
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.
Closes https://github.com/Cray/chapel-private/issues/7404.
This PR enables
paramiteration over ranges of enums. For instance, the following program produces one warning for every element inletters:Curiously the original reproducer in https://github.com/Cray/chapel-private/issues/7404 does not work as expected, because warnings are not emitted from inside
main. Not sure why that's the case, but it seems to be independent ofparamiteration.While there, this PR resolves signedness concerns (preventing overflow etc.).
The high-level outline of the change is to think of iteration over enums as iteration over the indices of their elements. This is similar to, but not the same as, the enum's
intvalues (not the same because users can change the values of enums by assigning them different integers, likered = 42).Testing
--dyno-resolve-onlyReviewed by @benharsh -- thanks!