File tree Expand file tree Collapse file tree 6 files changed +43
-1
lines changed
src/semmle/javascript/dataflow
test/library-tests/DataFlow Expand file tree Collapse file tree 6 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -741,7 +741,8 @@ module DataFlow {
741741 PropReadAsSourceNode ( ) {
742742 this = TPropNode ( any ( PropertyPattern p ) ) or
743743 this instanceof RestPatternNode or
744- this instanceof ElementPatternNode
744+ this instanceof ElementPatternNode or
745+ this = lvalueNode ( any ( ForOfStmt stmt ) .getLValue ( ) )
745746 }
746747 }
747748
@@ -826,6 +827,24 @@ module DataFlow {
826827 override string getPropertyName ( ) { result = astNode .getImportedName ( ) }
827828 }
828829
830+ /**
831+ * The left-hand side of a `for..of` statement, seen as a property read
832+ * on the object being iterated over.
833+ */
834+ private class ForOfLvalueAsPropRead extends PropRead {
835+ ForOfStmt stmt ;
836+
837+ ForOfLvalueAsPropRead ( ) {
838+ this = lvalueNode ( stmt .getLValue ( ) )
839+ }
840+
841+ override Node getBase ( ) { result = stmt .getIterationDomain ( ) .flow ( ) }
842+
843+ override Expr getPropertyNameExpr ( ) { none ( ) }
844+
845+ override string getPropertyName ( ) { none ( ) }
846+ }
847+
829848 /**
830849 * A data flow node representing an unused parameter.
831850 *
Original file line number Diff line number Diff line change 77| sources.js:3:11:3:11 | x | sources.js:4:10:4:10 | x |
88| sources.js:4:10:4:13 | x+19 | sources.js:3:1:5:6 | (functi ... \\n})(23) |
99| sources.js:5:4:5:5 | 23 | sources.js:3:11:3:11 | x |
10+ | sources.js:9:14:9:18 | array | sources.js:10:19:10:23 | array |
11+ | sources.js:9:14:9:18 | array | sources.js:11:23:11:27 | array |
12+ | sources.js:10:12:10:14 | key | sources.js:10:28:10:30 | key |
13+ | sources.js:11:12:11:18 | key | sources.js:11:32:11:34 | key |
14+ | sources.js:11:14:11:16 | key | sources.js:11:12:11:18 | key |
1015| tst.js:1:1:1:1 | x | tst.js:28:2:28:1 | x |
1116| tst.js:1:1:1:1 | x | tst.js:32:1:32:0 | x |
1217| tst.js:1:10:1:11 | fs | tst.js:1:10:1:11 | fs |
Original file line number Diff line number Diff line change 88| sources.js:1:6:1:11 | exceptional return of anonymous function | call |
99| sources.js:3:1:5:6 | exceptional return of (functi ... \\n})(23) | call |
1010| sources.js:3:2:5:1 | exceptional return of anonymous function | call |
11+ | sources.js:9:1:12:1 | exceptional return of function foo | call |
12+ | sources.js:9:14:9:18 | array | call |
13+ | sources.js:10:12:10:14 | key | heap |
14+ | sources.js:11:12:11:18 | key | heap |
15+ | sources.js:11:14:11:16 | key | heap |
1116| tst.js:1:10:1:11 | fs | import |
1217| tst.js:16:1:20:9 | exceptional return of (functi ... ("arg") | call |
1318| tst.js:16:2:20:1 | exceptional return of function f | call |
Original file line number Diff line number Diff line change 11| sources.js:1:6:1:6 | x |
22| sources.js:3:11:3:11 | x |
3+ | sources.js:9:14:9:18 | array |
34| tst.js:16:13:16:13 | a |
45| tst.js:32:12:32:12 | b |
56| tst.js:87:11:87:24 | { p: x, ...o } |
Original file line number Diff line number Diff line change 1313| sources.js:3:2:5:1 | functio ... x+19;\\n} |
1414| sources.js:3:11:3:11 | x |
1515| sources.js:7:1:7:3 | /x/ |
16+ | sources.js:9:1:9:0 | this |
17+ | sources.js:9:1:12:1 | functio ... ey; }\\n} |
18+ | sources.js:9:14:9:18 | array |
19+ | sources.js:10:12:10:14 | key |
20+ | sources.js:11:12:11:18 | { key } |
21+ | sources.js:11:14:11:16 | key |
1622| tst.js:1:1:1:0 | this |
1723| tst.js:1:1:1:24 | import ... m 'fs'; |
1824| tst.js:1:10:1:11 | fs |
6066| tst.js:72:9:72:9 | p |
6167| tst.js:72:9:72:11 | p() |
6268| tst.js:75:9:75:21 | import('foo') |
69+ | tst.js:80:10:80:10 | v |
6370| tst.js:83:11:83:28 | [ for (v of o) v ] |
6471| tst.js:85:11:85:28 | ( for (v of o) v ) |
6572| tst.js:87:1:96:2 | (functi ... r: 0\\n}) |
Original file line number Diff line number Diff line change @@ -5,3 +5,8 @@ new (x => x);
55} ) ( 23 ) ;
66
77/ x / ;
8+
9+ function foo ( array ) {
10+ for ( let key of array ) { key ; }
11+ for ( let { key } of array ) { key ; }
12+ }
You can’t perform that action at this time.
0 commit comments