forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
75 lines (64 loc) · 972 Bytes
/
test.js
File metadata and controls
75 lines (64 loc) · 972 Bytes
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
var x;
function f(a) {
var sum = 0;
// NOT OK
for (i=0; i<a.length; ++i)
sum += g(a[i]);
return sum;
}
function g(b) {
var prod = 1;
// NOT OK
for (i=0; i<b.length; ++i)
prod *= b[i];
return prod;
}
function h() {
// OK: x is declared as a global in the same toplevel
x = 23;
// NOT OK: y is not declared as a global in the same toplevel (though it is declared in test2.js)
y = 19;
// OK: console is live
console.log(x+y);
}
function k(x) {
try {
return x.y;
} catch(e) {
// OK: Error is not reachable (in our current CFG)
throw new Error();
}
}
function l() {
// OK: z is not used
z = 56;
}
function m() {
// OK: z is live
z += 23;
}
function n() {
// OK: z is live
z = z + 23;
}
function p() {
// NOT OK
return (z = a[i]) && z+23;
}
function q() {
// NOT OK
var x;
y = 23,
z = y+19;
}
function r() {
// NOT OK
z = {};
for (var p in z)
;
}
(function() {
for ([ unresolvable ] of o) {
unresolvable;
}
});