1414
1515import python
1616
17- private int len ( ExprList el ) {
18- result = count ( el .getAnItem ( ) )
19- }
17+ private int len ( ExprList el ) { result = count ( el .getAnItem ( ) ) }
2018
2119predicate mismatched ( Assign a , int lcount , int rcount , Location loc , string sequenceType ) {
2220 exists ( ExprList l , ExprList r |
23- ( a .getATarget ( ) .( Tuple ) .getElts ( ) = l or
24- a .getATarget ( ) .( List ) .getElts ( ) = l )
25- and
26- ( ( a .getValue ( ) .( Tuple ) .getElts ( ) = r and sequenceType = "tuple" ) or
27- ( a .getValue ( ) .( List ) .getElts ( ) = r and sequenceType = "list" ) )
28- and
21+ (
22+ a .getATarget ( ) .( Tuple ) .getElts ( ) = l or
23+ a .getATarget ( ) .( List ) .getElts ( ) = l
24+ ) and
25+ (
26+ a .getValue ( ) .( Tuple ) .getElts ( ) = r and sequenceType = "tuple"
27+ or
28+ a .getValue ( ) .( List ) .getElts ( ) = r and sequenceType = "list"
29+ ) and
2930 loc = a .getValue ( ) .getLocation ( ) and
3031 lcount = len ( l ) and
3132 rcount = len ( r ) and
@@ -35,24 +36,26 @@ predicate mismatched(Assign a, int lcount, int rcount, Location loc, string sequ
3536}
3637
3738predicate mismatched_tuple_rhs ( Assign a , int lcount , int rcount , Location loc ) {
38- exists ( ExprList l , TupleObject r , AstNode origin |
39- ( a .getATarget ( ) .( Tuple ) .getElts ( ) = l or
40- a .getATarget ( ) .( List ) .getElts ( ) = l )
41- and
42- a .getValue ( ) .refersTo ( r , origin ) and
39+ exists ( ExprList l , TupleValue r , AstNode origin |
40+ (
41+ a .getATarget ( ) .( Tuple ) .getElts ( ) = l or
42+ a .getATarget ( ) .( List ) .getElts ( ) = l
43+ ) and
44+ a .getValue ( ) .pointsTo ( r , origin ) and
4345 loc = origin .getLocation ( ) and
4446 lcount = len ( l ) and
45- rcount = r .getLength ( ) and
47+ rcount = r .length ( ) and
4648 lcount != rcount and
4749 not exists ( Starred s | l .getAnItem ( ) = s )
4850 )
4951}
5052
51-
5253from Assign a , int lcount , int rcount , Location loc , string sequenceType
5354where
5455 mismatched ( a , lcount , rcount , loc , sequenceType )
5556 or
5657 mismatched_tuple_rhs ( a , lcount , rcount , loc ) and
5758 sequenceType = "tuple"
58- select a , "Left hand side of assignment contains " + lcount + " variables, but right hand side is a $@ of length " + rcount + "." , loc , sequenceType
59+ select a ,
60+ "Left hand side of assignment contains " + lcount +
61+ " variables, but right hand side is a $@ of length " + rcount + "." , loc , sequenceType
0 commit comments