@@ -1414,23 +1414,28 @@ function getSequencePatternInfo(
14141414 { type : UnknownType . create ( ) , isUnbounded : true } ,
14151415 ] ;
14161416
1417- const tupleIndeterminateIndex = typeArgs . findIndex (
1417+ let tupleIndeterminateIndex = typeArgs . findIndex (
14181418 ( t ) => t . isUnbounded || isUnpackedTypeVarTuple ( t . type ) || isUnpackedTypeVar ( t . type )
14191419 ) ;
14201420
14211421 let tupleDeterminateEntryCount = typeArgs . length ;
14221422
14231423 // If the tuple contains an indeterminate entry, expand or remove that
14241424 // entry to match the length of the pattern if possible.
1425+ let expandedIndeterminate = false ;
14251426 if ( tupleIndeterminateIndex >= 0 ) {
14261427 tupleDeterminateEntryCount -- ;
14271428
14281429 while ( typeArgs . length < patternEntryCount ) {
14291430 typeArgs . splice ( tupleIndeterminateIndex , 0 , typeArgs [ tupleIndeterminateIndex ] ) ;
1431+ tupleDeterminateEntryCount ++ ;
1432+ tupleIndeterminateIndex ++ ;
1433+ expandedIndeterminate = true ;
14301434 }
14311435
14321436 if ( typeArgs . length > patternEntryCount && patternStarEntryIndex === undefined ) {
14331437 typeArgs . splice ( tupleIndeterminateIndex , 1 ) ;
1438+ tupleIndeterminateIndex = - 1 ;
14341439 }
14351440 }
14361441
@@ -1449,6 +1454,20 @@ function getSequencePatternInfo(
14491454 ( t ) => t . isUnbounded || isUnpackedTypeVarTuple ( t . type ) || isUnpackedTypeVar ( t . type )
14501455 ) ,
14511456 } ) ;
1457+
1458+ tupleDeterminateEntryCount -= entriesToCombine ;
1459+ if ( ! typeArgs [ patternStarEntryIndex ] . isUnbounded ) {
1460+ tupleDeterminateEntryCount ++ ;
1461+ }
1462+
1463+ // If the collapsed range included the tupleIndeterminateIndex, adjust
1464+ // it to reflect the new collapsed entry.
1465+ if (
1466+ tupleIndeterminateIndex >= patternStarEntryIndex &&
1467+ tupleIndeterminateIndex < patternStarEntryIndex + entriesToCombine
1468+ ) {
1469+ tupleIndeterminateIndex = patternStarEntryIndex ;
1470+ }
14521471 }
14531472
14541473 if ( typeArgs . length === patternEntryCount ) {
@@ -1459,6 +1478,7 @@ function getSequencePatternInfo(
14591478 // indeterminate-length entry that aligns to the star entry, we can
14601479 // assume it will always match.
14611480 if (
1481+ ! expandedIndeterminate &&
14621482 patternStarEntryIndex !== undefined &&
14631483 tupleIndeterminateIndex >= 0 &&
14641484 pattern . d . entries . length - 1 === tupleDeterminateEntryCount &&
0 commit comments