1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16// fixable
17let bar1 = 1;
18var foo1 = bar1;
19
20let bar2 = 1;
21let most2 = 1;
22var foo2 = bar2, toast2 = most2;
23
24let bar3 = 1;
25let most3 = 1;
26var foo3 = bar3; let toast3 = most3;
27
28let b4 = [];
29for (var a4 of b4) { console.log(a4); }
30
31let b5 = [];
32for (var a5 in b5) { console.log(a5); }
33
34let b6 = [];
35for (let a6 of b6) { var c6 = 1; console.log(c6); }
36
37let list7 = [];
38for (var i7 = 0; i7 < list7.length; ++i7) { foo(i7) }
39
40var {a8, b8 = a8} = {} // not fixable
41
42var a9 = b9; var b9 = 1
43
44var foo10 = 1
45
46declare var foo11 = 2;
47
48// not fixable
49var fx12 = function (i12 = 0) { if (i12 < 5) { return fx12(i12 + 1); } console.log(i12); }; fx12();
50
51var foo13 = function () { foo13() };
52
53var foo14 = () => foo14();
54
55// fixable
56var bar15 = foo15; var foo15 = function () { foo15(); };
57
58var bar16 = function () { foo16(); }; var foo16 = function() {};
59
60// not fixable
61for (var i17 = 0, i17 = 0; false;);
62
63var i18 = 0; for (var i18 = 1; false;); console.log(i18);
64
65var a19, b19, c19; var a19;
66
67let b20 = 1;
68var a20; if (b20) { var a20; }
69
70let foo21 = 1;
71if (foo21) { var a21, b21, c21; } a21;
72
73for (var i22 = 0; i22 < 10; ++i22) {} i22;
74
75let obj23 = [];
76for (var a23 in obj23) {} a23;
77
78let list24 = [];
79for (var a24 of list24) {} a24;
80
81let a25 = 1;
82switch (a25) { case 0: var b25 = 1 }
83
84let b26 = [];
85let arr26 = [];
86for (var a26 of b26) { arr26.push(() => a26); }
87
88let b27 = [];
89for (let a27 of b27) { var c27; console.log(c27); c27 = 'hello'; }
90
91var a28 = a28
92
93var {a29 = a29} = {}
94
95var {a30 = b30, b30} = {}
96
97var a31 = b31, b31 = 1
98
99function foo32() { a32 } var a32 = 1; foo32()
100
101let foo33 = 1;
102if (foo33) var bar33 = 1;
103
104// var foo34 = 1
105
106// { var foo35 = 1 }
107
108if (true) { var foo36 = 1 }
109
110function foo37() { var let; }
111
112// how to test it, let keyword should stay let keyword
113// function foo38() { var { let } = {}; }
114
115var foo39 = (function () { foo39(); })();
116
117let bar40 = function(a) {};
118var foo40 = bar40(function () { foo40(); });
119
120var bar41 = foo41, foo41 = function () { foo41(); };
121
122var { foo42 = foo42 } = function () { foo42(); };
123
124var { bar43 = foo43, foo43 } = function () { foo43(); };
125