-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtst.js
More file actions
106 lines (84 loc) · 2.89 KB
/
tst.js
File metadata and controls
106 lines (84 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { fs } from 'fs';
let x = 42;
let y = "hi";
let z;
fs; // def-use flow
x; // def-use flow
(x); // flow through parentheses
x, y; // flow through comma operator
x && y; // flow through short-circuiting operator
x || y; // flow through short-circuiting operator
z = y; // flow through assignment
z ? x : y; // flow through conditional operator
(function f(a) { // flow into IIFE
if (Math.random() > 0.5)
return a;
return "";
})("arg"); // flow out of IIFE
let { readFileSync } = fs;
readFileSync; // flow out of destructuring assignment
++x;
x; // def-use flow
(() =>
x // imprecise def-use flow for captured variables
)();
function g(b) { // no flow through general calls
return x; // imprecise def-use flow for captured variables
}
g(true); // no flow through general calls
var o = {
x: null,
m() {
this;
}
};
o.x; // no flow through properties
o.m(); // no flow through method calls
global = "";
global; // no flow through global variables
class A extends B {
constructor() {
super(42); // no attempt is made to resolve `super`
new.target; // or `new.target`
}
}
A; // def-use flow
`x: ${x}`;
tag `x: ${x}`; // tagged templates are not analysed
g; // def-use flow
::o.m; // function-bind is not analysed
o::g; // function-bind is not analysed
function* h() {
yield 42; // `yield` is not analysed
var tmp = function.sent; // `function.sent` is not analysed
}
let iter = h();
iter.next(23);
async function k() {
await p(); // `await` is not analysed
}
let m = import('foo'); // dynamic `import` is not analysed
for (let i in o) // for-in loops are not analysed
i;
for (let v of o) // for-of loops are not analysed
v;
var vs1 = [ for (v of o) v ]; // array comprehensions are not analysed
var vs2 = ( for (v of o) v ); // generator comprehensions are not analysed
(function({ p: x, ...o }) {
let { q: y } = o;
var z;
({ r: z } = o);
return x + y + z;
})({
p: 19,
q: 23,
r: 0
});
(function([ x, ...rest ]) {
let [ y ] = rest;
var z;
[ , z ] = rest;
return x + y + z;
})([ 19, 23, 0 ]);
x ?? y; // flow through short-circuiting operator
// semmle-extractor-options: --experimental