-
Notifications
You must be signed in to change notification settings - Fork 587
/
js-class-related-unterminated.js
62 lines (54 loc) · 1.12 KB
/
js-class-related-unterminated.js
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
var Cls = {
// add a member just so Cls is recognized as a class from the start
A: {}
}
Cls.B = function(a, b) {
this.a = a;
this.b = b;
}
Cls.B.Sub = function() {
this.a = 0
}
Cls.B.prototype.m1 = function(a) {
this.a = a;
if (a > 2) {
this.a *= 2
}
}
Cls.B.prototype.m2 = function(b) {
var a = b
}
Cls.B.prototype.m3 = function(c) {
this.c = c
}
Cls.B.prototype.m4 = function(d) {
this.d = d
}
Cls.B.prototype.m5 = function(e) {
/* this should rather be written `Cls.B.Sub.prototype.dyn1 = this.m6`, but
* then parser then thinks it's a child of this very scope. it isn't really
* possible to fix this as the only reason it's actually not a child of the
* current scope is because it exists in the root scope but not in this one */
var Sub = Cls.B.Sub;
Sub.prototype.dyn1 = this.m4
}
Cls.B.prototype.m6 = function(f) {
}
Cls.C = function () {
this.a = 0;
}
Cls.C.prototype = {
n1: function() {
Cls.C.prototype = Cls.C.prototype
},
n2: function() {
}
}
function main() {
var c = new Cls.B(1, 2);
var d = new Cls.B.Sub();
print(d.dyn1);
c.m5();
print(d.dyn1);
}
main();