Skip to content

Commit

Permalink
Remove duplicate checking for unknown iterables
Browse files Browse the repository at this point in the history
Signed-off-by: Danila Fedorin <[email protected]>
  • Loading branch information
DanilaFe committed Nov 20, 2024
1 parent 81b4905 commit 6399bfa
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions frontend/lib/resolution/Resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5071,6 +5071,7 @@ static IterDetails resolveNonZipExpression(Resolver& rv,

if (iterandRe.type().isUnknownOrErroneous()) {
// The iterand is unknown, no work to do.
return {};
}

// Resolve iterators, stopping immediately when we get a valid yield type.
Expand Down Expand Up @@ -5154,11 +5155,11 @@ resolveIterTypeWithTag(Resolver& rv,
// Inspect the resolution result to determine what should be done next.
auto& iterandRE = rv.byPostorder.byAst(iterand);
auto iterandType = iterandRE.type();
CHPL_ASSERT(!iterandType.isUnknownOrErroneous());

auto& MSC = iterandRE.mostSpecific();
auto fn = MSC.only() ? MSC.only().fn() : nullptr;

bool wasIterandTypeResolved = !iterandType.isUnknownOrErroneous();
// For iterator forwarding, we can write serial 'for' loops over tagged iterator calls
bool treatAsSerial = fn &&
(fn->isSerialIterator(context) || isExplicitlyTaggedIteratorCall(context, iterandRE, fn));
Expand All @@ -5173,18 +5174,14 @@ resolveIterTypeWithTag(Resolver& rv,
(iterandType.type() && iterandType.type()->isLoopExprIteratorType() && needSerial);

// The iterand was a call to a serial iterator, and we need a serial iterator.
if (wasMatchingIterResolved && wasIterandTypeResolved) {
if (wasMatchingIterResolved) {
CHPL_ASSERT(iterandType.type()->isIteratorType() &&
iterandType.type() == iteratingOver &&
"an iterator was resolved, expecting an iterator type");
// We no longer have a call resolution result that produced the MSC,
// so just create a mock one here.
outIterPieces = { iteratingOver, TheseResolutionResult::success(iterandType) };
return yieldTypeForIterator(rv.rc, iterandType.type()->toIteratorType());

// There's nothing to do in this case, so error out.
} else if (needSerial && !wasIterandTypeResolved) {
return error;
}

// The iterand is either not an iterator (but could have a 'these' method)
Expand Down

0 comments on commit 6399bfa

Please sign in to comment.