Skip to content

Commit abb501d

Browse files
committed
[RequirementMachine] Add verification for rules involving shape symbols.
1 parent 313138c commit abb501d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/AST/RequirementMachine/RewriteSystem.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,12 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
551551
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Layout);
552552
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Superclass);
553553
ASSERT_RULE(symbol.getKind() != Symbol::Kind::ConcreteType);
554+
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Shape);
555+
}
556+
557+
// A shape symbol must follow a generic param symbol
558+
if (symbol.getKind() == Symbol::Kind::Shape) {
559+
ASSERT_RULE(index > 0 && lhs[index - 1].getKind() == Symbol::Kind::GenericParam);
554560
}
555561

556562
if (!rule.isLHSSimplified() &&
@@ -595,6 +601,15 @@ void RewriteSystem::verifyRewriteRules(ValidityPolicy policy) const {
595601
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Superclass);
596602
ASSERT_RULE(symbol.getKind() != Symbol::Kind::ConcreteType);
597603

604+
if (index != lhs.size() - 1) {
605+
ASSERT_RULE(symbol.getKind() != Symbol::Kind::Shape);
606+
}
607+
608+
// A shape symbol must follow a generic param symbol
609+
if (symbol.getKind() == Symbol::Kind::Shape) {
610+
ASSERT_RULE(index > 0 && rhs[index - 1].getKind() == Symbol::Kind::GenericParam);
611+
}
612+
598613
// Completion can introduce a rule of the form
599614
//
600615
// (T.[P] => T.[concrete: C : P])

0 commit comments

Comments
 (0)