Added more tests

Testing SILGen & IRGen tuple keypath generation
Added tuple element type check in SILVerifier
This commit is contained in:
technicated
2018-12-29 16:55:19 +01:00
committed by Andrea Tomarelli
parent a0ed29d326
commit d7324b977e
9 changed files with 261 additions and 11 deletions

View File

@@ -389,10 +389,18 @@ void verifyKeyPathComponent(SILModule &M,
"invalid baseTy, should have been a TupleType");
auto tupleTy = loweredBaseTy.getAs<TupleType>();
require(component.getTupleIndex() < tupleTy->getNumElements(),
auto eltIdx = component.getTupleIndex();
require(eltIdx < tupleTy->getNumElements(),
"invalid element index, greater than # of tuple elements");
auto eltTy = tupleTy->getElementType(eltIdx)
->getReferenceStorageReferent()
->getCanonicalType();
require(eltTy == componentTy,
"tuple element type should match the type of the component");
break;
}
}