forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtst.js
More file actions
65 lines (52 loc) · 1.02 KB
/
tst.js
File metadata and controls
65 lines (52 loc) · 1.02 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
function Point(x, y) {
this.x = x;
this.y = y;
}
new Point(23, 42);
Point(56, 72);
function RobustPoint(x, y) {
if (!(this instanceof RobustPoint))
return new RobustPoint(x, y);
this.x = x;
this.y = y;
}
new RobustPoint(23, 42);
RobustPoint(56, 72);
function RobustPoint2(x, y) {
if (this.constructor !== RobustPoint2)
return new RobustPoint2(x, y);
this.x = x;
this.y = y;
}
new RobustPoint2(23, 42);
RobustPoint2(56, 72);
function RobustPoint3(x, y) {
var self = this;
if (self.constructor !== arguments.callee)
return new RobustPoint3(x, y);
this.x = x;
this.y = y;
}
new RobustPoint3(23, 42);
RobustPoint3(56, 72);
function RobustPoint4(x, y) {
if (this.constructor !== arguments.callee)
return new arguments.callee(x, y);
this.x = x;
this.y = y;
}
new RobustPoint4(23, 42);
RobustPoint4(56, 72);
// OK: Error is an external function
new Error();
Error();
class C {}
new C();
C(); // NOT OK, but flagged by IllegalInvocation
(function() {
function A(x) {
this.x = x;
}
new A(42);
A.call({}, 23);
})();