From 8bf8ebc8445b218919e912c8999388ec04be9cfa Mon Sep 17 00:00:00 2001 From: "Steven S. Lyubomirsky" Date: Fri, 24 May 2019 12:30:20 -0700 Subject: [PATCH] Make partial matching more aggressively search for clash --- src/relay/pass/match_exhaustion.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/relay/pass/match_exhaustion.cc b/src/relay/pass/match_exhaustion.cc index 0b87925ea1c81..173d6eacf528f 100644 --- a/src/relay/pass/match_exhaustion.cc +++ b/src/relay/pass/match_exhaustion.cc @@ -70,11 +70,20 @@ class CandidateChecker : public PatternFunctorpatterns.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; }