@@ -3097,6 +3097,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3097
3097
3098
3098
void checkTupleInst (TupleInst *TI) {
3099
3099
CanTupleType ResTy = requireObjectType (TupleType, TI, " Result of tuple" );
3100
+ require (!ResTy.containsPackExpansionType (),
3101
+ " tuple instruction cannot be used with tuples containing "
3102
+ " pack expansions" );
3100
3103
3101
3104
require (TI->getElements ().size () == ResTy->getNumElements (),
3102
3105
" Tuple field count mismatch!" );
@@ -3288,6 +3291,10 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3288
3291
void checkTupleExtractInst (TupleExtractInst *EI) {
3289
3292
CanTupleType operandTy = requireObjectType (TupleType, EI->getOperand (),
3290
3293
" Operand of tuple_extract" );
3294
+ require (!operandTy.containsPackExpansionType (),
3295
+ " tuple_extract cannot be used with tuples containing "
3296
+ " pack expansions" );
3297
+
3291
3298
require (EI->getType ().isObject (),
3292
3299
" result of tuple_extract must be object" );
3293
3300
@@ -3343,21 +3350,21 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
3343
3350
}
3344
3351
3345
3352
void checkTupleElementAddrInst (TupleElementAddrInst *EI) {
3346
- SILType operandTy = EI->getOperand ()->getType ();
3347
- require (operandTy.isAddress (),
3348
- " must derive element_addr from address" );
3349
3353
require (EI->getType ().isAddress (),
3350
3354
" result of tuple_element_addr must be address" );
3351
- require (operandTy.is <TupleType>(),
3352
- " must derive tuple_element_addr from tuple" );
3353
-
3354
- ArrayRef<TupleTypeElt> fields = operandTy.castTo <TupleType>()->getElements ();
3355
- require (EI->getFieldIndex () < fields.size (),
3356
- " invalid field index for element_addr instruction" );
3355
+ SILType operandTy = EI->getOperand ()->getType ();
3356
+ auto tupleType = requireAddressType (TupleType, operandTy,
3357
+ " operand of tuple_element_addr must be the address of a tuple" );
3358
+ require (!tupleType.containsPackExpansionType (),
3359
+ " tuple_element_addr cannot be used with tuples containing "
3360
+ " pack expansions" );
3361
+
3362
+ require (EI->getFieldIndex () < tupleType->getNumElements (),
3363
+ " invalid field index for tuple_element_addr instruction" );
3357
3364
if (EI->getModule ().getStage () != SILStage::Lowered) {
3358
3365
requireSameType (
3359
3366
EI->getType ().getASTType (),
3360
- CanType (fields[ EI->getFieldIndex ()]. getType ()),
3367
+ tupleType. getElementType ( EI->getFieldIndex ()),
3361
3368
" type of tuple_element_addr does not match type of element" );
3362
3369
}
3363
3370
}
0 commit comments