@@ -563,13 +563,19 @@ module LocalFlow {
563563 exists ( IsExpr e |
564564 e1 = e .getExpr ( ) and
565565 e2 = e .getPattern ( ) and
566- e2 instanceof TuplePatternExpr
566+ (
567+ e2 instanceof TuplePatternExpr or
568+ e2 instanceof RecursivePatternExpr
569+ )
567570 )
568571 or
569572 exists ( Switch sw |
570573 e1 = sw .getExpr ( ) and
571574 e2 = sw .getACase ( ) .getPattern ( ) and
572- e2 instanceof TuplePatternExpr
575+ (
576+ e2 instanceof TuplePatternExpr or
577+ e2 instanceof RecursivePatternExpr
578+ )
573579 )
574580 }
575581
@@ -823,7 +829,8 @@ private predicate fieldOrPropertyStore(ContentSet c, Expr src, Expr q, boolean p
823829 te = q and
824830 src = te .getArgument ( pragma [ only_bind_into ] ( i ) ) and
825831 te .isConstruction ( ) and
826- f = q .getType ( ) .( TupleType ) .getElement ( pragma [ only_bind_into ] ( i ) ) and
832+ // TODO: Should this be unBoundDeclaration() as well - otherwise it is not symmetric with the readStep?
833+ f = q .getType ( ) .( TupleType ) .getElement ( pragma [ only_bind_into ] ( i ) ) .getUnboundDeclaration ( ) and
827834 postUpdate = false
828835 )
829836 )
@@ -2208,6 +2215,23 @@ predicate storeStep(Node node1, ContentSet c, Node node2) {
22082215 storeStepDelegateCall ( node1 , c , node2 )
22092216}
22102217
2218+ private predicate readStepPattern ( Node node1 , Content c , Node node2 ) {
2219+ exists ( RecursivePatternExpr parent , PatternExpr child , int i |
2220+ node1 .asExpr ( ) = parent and
2221+ child = parent .getPositionalPatterns ( ) .getPattern ( i ) and
2222+ c .( FieldContent ) .getField ( ) = parent .getType ( ) .( TupleType ) .getElement ( i ) .getUnboundDeclaration ( )
2223+ |
2224+ child = node2 .asExpr ( ) .( RecursivePatternExpr )
2225+ or
2226+ child = node2 .asExpr ( ) .( TuplePatternExpr )
2227+ or
2228+ exists ( AssignableDefinitions:: PatternDefinition lvd |
2229+ node2 .( AssignableDefinitionNode ) .getDefinition ( ) = lvd and
2230+ child = lvd .getDeclaration ( )
2231+ )
2232+ )
2233+ }
2234+
22112235private predicate readContentStep ( Node node1 , Content c , Node node2 ) {
22122236 arrayRead ( node1 .asExpr ( ) , node2 .asExpr ( ) ) and
22132237 c instanceof ElementContent
@@ -2255,6 +2279,8 @@ private predicate readContentStep(Node node1, Content c, Node node2) {
22552279 )
22562280 )
22572281 or
2282+ readStepPattern ( node1 , c , node2 )
2283+ or
22582284 VariableCapture:: readStep ( node1 , c , node2 )
22592285}
22602286
0 commit comments