Skip to content

Commit

Permalink
Make partial matching more aggressively search for clash
Browse files Browse the repository at this point in the history
  • Loading branch information
slyubomirsky committed May 24, 2019
1 parent 56ff693 commit 8bf8ebc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/relay/pass/match_exhaustion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,20 @@ class CandidateChecker : public PatternFunctor<MatchResult(const Pattern&, const

// now check that subpatterns match
CHECK(op->patterns.size() == ctor_cand->patterns.size());
bool unspecified = false;
for (size_t i = 0; i < op->patterns.size(); i++) {
MatchResult submatch = this->Check(op->patterns[i], ctor_cand->patterns[i]);
if (submatch != MatchResult::kMatch) {
return submatch;
// if we have a clash anywhere, then we can return clash
if (submatch == MatchResult::kClash) {
return MatchResult::kClash;
}
if (submatch == MatchResult::kUnspecified) {
unspecified = true;
}
}
// only return unspecified if we have ruled out a clash
if (unspecified) {
return MatchResult::kUnspecified;
}
return MatchResult::kMatch;
}
Expand Down

0 comments on commit 8bf8ebc

Please sign in to comment.