Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: test/cctest/parsing/test-preparser.cc

Issue 2679263002: Revert of [parsing] Fix maybe-assigned for loop variables. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.cc ('k') | test/cctest/scope-test-helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast/ast.h" 5 #include "src/ast/ast.h"
6 #include "src/compiler.h" 6 #include "src/compiler.h"
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 #include "src/parsing/parse-info.h" 8 #include "src/parsing/parse-info.h"
9 #include "src/parsing/parsing.h" 9 #include "src/parsing/parsing.h"
10 10
(...skipping 12 matching lines...) Expand all
23 const char* prefix = "(function outer() { "; 23 const char* prefix = "(function outer() { ";
24 const char* suffix = " })();"; 24 const char* suffix = " })();";
25 int prefix_len = Utf8LengthHelper(prefix); 25 int prefix_len = Utf8LengthHelper(prefix);
26 int suffix_len = Utf8LengthHelper(suffix); 26 int suffix_len = Utf8LengthHelper(suffix);
27 27
28 // The scope start positions must match; note the extra space in lazy_inner. 28 // The scope start positions must match; note the extra space in lazy_inner.
29 const char* lazy_inner = " function inner(%s) { %s }"; 29 const char* lazy_inner = " function inner(%s) { %s }";
30 const char* eager_inner = "(function inner(%s) { %s })()"; 30 const char* eager_inner = "(function inner(%s) { %s })()";
31 31
32 struct { 32 struct {
33 bool precise_maybe_assigned;
34 const char* params; 33 const char* params;
35 const char* source; 34 const char* source;
36 } inners[] = { 35 } inners[] = {
37 // Simple cases 36 // Simple cases
38 {1, "", "var1;"}, 37 {"", "var1;"},
39 {1, "", "var1 = 5;"}, 38 {"", "var1 = 5;"},
40 {1, "", "if (true) {}"}, 39 {"", "if (true) {}"},
41 {1, "", "function f1() {}"}, 40 {"", "function f1() {}"},
42 41
43 // Var declarations and assignments. 42 // Var declarations and assignments.
44 {1, "", "var var1;"}, 43 {"", "var var1;"},
45 {1, "", "var var1; var1 = 5;"}, 44 {"", "var var1; var1 = 5;"},
46 {0, "", "if (true) { var var1; }"}, 45 {"", "if (true) { var var1; }"},
47 {1, "", "if (true) { var var1; var1 = 5; }"}, 46 {"", "if (true) { var var1; var1 = 5; }"},
48 {1, "", "var var1; function f() { var1; }"}, 47 {"", "var var1; function f() { var1; }"},
49 {1, "", "var var1; var1 = 5; function f() { var1; }"}, 48 {"", "var var1; var1 = 5; function f() { var1; }"},
50 {1, "", "var var1; function f() { var1 = 5; }"}, 49 {"", "var var1; function f() { var1 = 5; }"},
51 50
52 // Let declarations and assignments. 51 // Let declarations and assignments.
53 {1, "", "let var1;"}, 52 {"", "let var1;"},
54 {1, "", "let var1; var1 = 5;"}, 53 {"", "let var1; var1 = 5;"},
55 {1, "", "if (true) { let var1; }"}, 54 {"", "if (true) { let var1; }"},
56 {1, "", "if (true) { let var1; var1 = 5; }"}, 55 {"", "if (true) { let var1; var1 = 5; }"},
57 {1, "", "let var1; function f() { var1; }"}, 56 {"", "let var1; function f() { var1; }"},
58 {1, "", "let var1; var1 = 5; function f() { var1; }"}, 57 {"", "let var1; var1 = 5; function f() { var1; }"},
59 {1, "", "let var1; function f() { var1 = 5; }"}, 58 {"", "let var1; function f() { var1 = 5; }"},
60 59
61 // Const declarations. 60 // Const declarations.
62 {1, "", "const var1 = 5;"}, 61 {"", "const var1 = 5;"},
63 {1, "", "if (true) { const var1 = 5; }"}, 62 {"", "if (true) { const var1 = 5; }"},
64 {1, "", "const var1 = 5; function f() { var1; }"}, 63 {"", "const var1 = 5; function f() { var1; }"},
65 64
66 // Redeclarations. 65 // Redeclarations.
67 {1, "", "var var1; var var1;"}, 66 {"", "var var1; var var1;"},
68 {1, "", "var var1; var var1; var1 = 5;"}, 67 {"", "var var1; var var1; var1 = 5;"},
69 {1, "", "var var1; if (true) { var var1; }"}, 68 {"", "var var1; if (true) { var var1; }"},
70 {1, "", "if (true) { var var1; var var1; }"}, 69 {"", "if (true) { var var1; var var1; }"},
71 {1, "", "var var1; if (true) { var var1; var1 = 5; }"}, 70 {"", "var var1; if (true) { var var1; var1 = 5; }"},
72 {1, "", "if (true) { var var1; var var1; var1 = 5; }"}, 71 {"", "if (true) { var var1; var var1; var1 = 5; }"},
73 {1, "", "var var1; var var1; function f() { var1; }"}, 72 {"", "var var1; var var1; function f() { var1; }"},
74 {1, "", "var var1; var var1; function f() { var1 = 5; }"}, 73 {"", "var var1; var var1; function f() { var1 = 5; }"},
75 74
76 // Shadowing declarations. 75 // Shadowing declarations.
77 {1, "", "var var1; if (true) { var var1; }"}, 76 {"", "var var1; if (true) { var var1; }"},
78 {1, "", "var var1; if (true) { let var1; }"}, 77 {"", "var var1; if (true) { let var1; }"},
79 {1, "", "let var1; if (true) { let var1; }"}, 78 {"", "let var1; if (true) { let var1; }"},
80 79
81 {1, "", "var var1; if (true) { const var1 = 0; }"}, 80 {"", "var var1; if (true) { const var1 = 0; }"},
82 {1, "", "const var1 = 0; if (true) { const var1 = 0; }"}, 81 {"", "const var1 = 0; if (true) { const var1 = 0; }"},
83 82
84 // Arguments and this. 83 // Arguments and this.
85 {1, "", "arguments;"}, 84 {"", "arguments;"},
86 {1, "", "arguments = 5;"}, 85 {"", "arguments = 5;"},
87 {1, "", "if (true) { arguments; }"}, 86 {"", "if (true) { arguments; }"},
88 {1, "", "if (true) { arguments = 5; }"}, 87 {"", "if (true) { arguments = 5; }"},
89 {1, "", "function f() { arguments; }"}, 88 {"", "function f() { arguments; }"},
90 {1, "", "function f() { arguments = 5; }"}, 89 {"", "function f() { arguments = 5; }"},
91 90
92 {1, "", "this;"}, 91 {"", "this;"},
93 {1, "", "if (true) { this; }"}, 92 {"", "if (true) { this; }"},
94 {1, "", "function f() { this; }"}, 93 {"", "function f() { this; }"},
95 94
96 // Variable called "arguments" 95 // Variable called "arguments"
97 {1, "", "var arguments;"}, 96 {"", "var arguments;"},
98 {1, "", "var arguments; arguments = 5;"}, 97 {"", "var arguments; arguments = 5;"},
99 {0, "", "if (true) { var arguments; }"}, 98 {"", "if (true) { var arguments; }"},
100 {1, "", "if (true) { var arguments; arguments = 5; }"}, 99 {"", "if (true) { var arguments; arguments = 5; }"},
101 {1, "", "var arguments; function f() { arguments; }"}, 100 {"", "var arguments; function f() { arguments; }"},
102 {1, "", "var arguments; arguments = 5; function f() { arguments; }"}, 101 {"", "var arguments; arguments = 5; function f() { arguments; }"},
103 {1, "", "var arguments; function f() { arguments = 5; }"}, 102 {"", "var arguments; function f() { arguments = 5; }"},
104 103
105 {1, "", "let arguments;"}, 104 {"", "let arguments;"},
106 {1, "", "let arguments; arguments = 5;"}, 105 {"", "let arguments; arguments = 5;"},
107 {1, "", "if (true) { let arguments; }"}, 106 {"", "if (true) { let arguments; }"},
108 {1, "", "if (true) { let arguments; arguments = 5; }"}, 107 {"", "if (true) { let arguments; arguments = 5; }"},
109 {1, "", "let arguments; function f() { arguments; }"}, 108 {"", "let arguments; function f() { arguments; }"},
110 {1, "", "let arguments; arguments = 5; function f() { arguments; }"}, 109 {"", "let arguments; arguments = 5; function f() { arguments; }"},
111 {1, "", "let arguments; function f() { arguments = 5; }"}, 110 {"", "let arguments; function f() { arguments = 5; }"},
112 111
113 {1, "", "const arguments = 5;"}, 112 {"", "const arguments = 5;"},
114 {1, "", "if (true) { const arguments = 5; }"}, 113 {"", "if (true) { const arguments = 5; }"},
115 {1, "", "const arguments = 5; function f() { arguments; }"}, 114 {"", "const arguments = 5; function f() { arguments; }"},
116 115
117 // Destructuring declarations. 116 // Destructuring declarations.
118 {1, "", "var [var1, var2] = [1, 2];"}, 117 {"", "var [var1, var2] = [1, 2];"},
119 {1, "", "var [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, 118 {"", "var [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"},
120 {1, "", "var [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, 119 {"", "var [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"},
121 {1, "", "var [var1, ...var2] = [1, 2, 3];"}, 120 {"", "var [var1, ...var2] = [1, 2, 3];"},
122 121
123 {1, "", "var {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, 122 {"", "var {var1: var2, var3: var4} = {var1: 1, var3: 2};"},
124 {1, "", 123 {"",
125 "var {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, 124 "var {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"},
126 {1, "", 125 {"", "var {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"},
127 "var {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, 126
128 127 {"", "let [var1, var2] = [1, 2];"},
129 {1, "", "let [var1, var2] = [1, 2];"}, 128 {"", "let [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"},
130 {1, "", "let [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, 129 {"", "let [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"},
131 {1, "", "let [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, 130 {"", "let [var1, ...var2] = [1, 2, 3];"},
132 {1, "", "let [var1, ...var2] = [1, 2, 3];"}, 131
133 132 {"", "let {var1: var2, var3: var4} = {var1: 1, var3: 2};"},
134 {1, "", "let {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, 133 {"",
135 {1, "",
136 "let {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, 134 "let {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"},
137 {1, "", 135 {"", "let {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"},
138 "let {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"}, 136
139 137 {"", "const [var1, var2] = [1, 2];"},
140 {1, "", "const [var1, var2] = [1, 2];"}, 138 {"", "const [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"},
141 {1, "", "const [var1, var2, [var3, var4]] = [1, 2, [3, 4]];"}, 139 {"", "const [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"},
142 {1, "", "const [{var1: var2}, {var3: var4}] = [{var1: 1}, {var3: 2}];"}, 140 {"", "const [var1, ...var2] = [1, 2, 3];"},
143 {1, "", "const [var1, ...var2] = [1, 2, 3];"}, 141
144 142 {"", "const {var1: var2, var3: var4} = {var1: 1, var3: 2};"},
145 {1, "", "const {var1: var2, var3: var4} = {var1: 1, var3: 2};"}, 143 {"",
146 {1, "",
147 "const {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"}, 144 "const {var1: var2, var3: {var4: var5}} = {var1: 1, var3: {var4: 2}};"},
148 {1, "", 145 {"", "const {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"},
149 "const {var1: var2, var3: [var4, var5]} = {var1: 1, var3: [2, 3]};"},
150 146
151 // Referencing the function variable. 147 // Referencing the function variable.
152 {1, "", "inner;"}, 148 {"", "inner;"},
153 {1, "", "function f1() { f1; }"}, 149 {"", "function f1() { f1; }"},
154 {1, "", "function f1() { inner; }"}, 150 {"", "function f1() { inner; }"},
155 {1, "", "function f1() { function f2() { f1; } }"}, 151 {"", "function f1() { function f2() { f1; } }"},
156 {1, "", "function arguments() {}"}, 152 {"", "function arguments() {}"},
157 {1, "", "function f1() {} function f1() {}"}, 153 {"", "function f1() {} function f1() {}"},
158 {1, "", "var f1; function f1() {}"}, 154 {"", "var f1; function f1() {}"},
159 155
160 // Assigning to the function variable. 156 // Assigning to the function variable.
161 {1, "", "inner = 3;"}, 157 {"", "inner = 3;"},
162 {1, "", "function f1() { f1 = 3; }"}, 158 {"", "function f1() { f1 = 3; }"},
163 {1, "", "function f1() { f1; } f1 = 3;"}, 159 {"", "function f1() { f1; } f1 = 3;"},
164 {1, "", "function arguments() {} arguments = 8"}, 160 {"", "function arguments() {} arguments = 8"},
165 {1, "", "function f1() {} f1 = 3; function f1() {}"}, 161 {"", "function f1() {} f1 = 3; function f1() {}"},
166 162
167 // Evals. 163 // Evals.
168 {1, "", "var var1; eval('');"}, 164 {"", "var var1; eval('');"},
169 {1, "", "var var1; function f1() { eval(''); }"}, 165 {"", "var var1; function f1() { eval(''); }"},
170 {1, "", "let var1; eval('');"}, 166 {"", "let var1; eval('');"},
171 {1, "", "let var1; function f1() { eval(''); }"}, 167 {"", "let var1; function f1() { eval(''); }"},
172 {1, "", "const var1 = 10; eval('');"}, 168 {"", "const var1 = 10; eval('');"},
173 {1, "", "const var1 = 10; function f1() { eval(''); }"}, 169 {"", "const var1 = 10; function f1() { eval(''); }"},
174 170
175 // Standard for loops. 171 // Standard for loops.
176 {1, "", "for (var var1 = 0; var1 < 10; ++var1) { }"}, 172 {"", "for (var var1 = 0; var1 < 10; ++var1) { }"},
177 {1, "", "for (let var1 = 0; var1 < 10; ++var1) { }"}, 173 {"", "for (let var1 = 0; var1 < 10; ++var1) { }"},
178 {1, "", "for (const var1 = 0; var1 < 10; ++var1) { }"}, 174 {"", "for (const var1 = 0; var1 < 10; ++var1) { }"},
179 175
180 {1, "", 176 {"",
181 "for (var var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, 177 "for (var var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"},
182 {1, "", 178 {"",
183 "for (let var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, 179 "for (let var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"},
184 {1, "", 180 {"",
185 "for (const var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"}, 181 "for (const var1 = 0; var1 < 10; ++var1) { function foo() { var1; } }"},
186 {1, "", 182 {"",
187 "'use strict'; for (var var1 = 0; var1 < 10; ++var1) { function foo() { " 183 "'use strict'; for (var var1 = 0; var1 < 10; ++var1) { function foo() { "
188 "var1; } }"}, 184 "var1; } }"},
189 {1, "", 185 {"",
190 "'use strict'; for (let var1 = 0; var1 < 10; ++var1) { function foo() { " 186 "'use strict'; for (let var1 = 0; var1 < 10; ++var1) { function foo() { "
191 "var1; } }"}, 187 "var1; } }"},
192 {1, "", 188 {"",
193 "'use strict'; for (const var1 = 0; var1 < 10; ++var1) { function foo() " 189 "'use strict'; for (const var1 = 0; var1 < 10; ++var1) { function foo() "
194 "{ var1; } }"}, 190 "{ var1; } }"},
195 191
196 // For of loops 192 // For of loops
197 {1, "", "for (var1 of [1, 2]) { }"}, 193 {"", "for (var1 of [1, 2]) { }"},
198 {1, "", "for (var var1 of [1, 2]) { }"}, 194 {"", "for (var var1 of [1, 2]) { }"},
199 {1, "", "for (let var1 of [1, 2]) { }"}, 195 {"", "for (let var1 of [1, 2]) { }"},
200 {1, "", "for (const var1 of [1, 2]) { }"}, 196 {"", "for (const var1 of [1, 2]) { }"},
201 197
202 {1, "", "for (var1 of [1, 2]) { var1; }"}, 198 {"", "for (var1 of [1, 2]) { var1; }"},
203 {1, "", "for (var var1 of [1, 2]) { var1; }"}, 199 {"", "for (var var1 of [1, 2]) { var1; }"},
204 {1, "", "for (let var1 of [1, 2]) { var1; }"}, 200 {"", "for (let var1 of [1, 2]) { var1; }"},
205 {1, "", "for (const var1 of [1, 2]) { var1; }"}, 201 {"", "for (const var1 of [1, 2]) { var1; }"},
206 202
207 {1, "", "for (var1 of [1, 2]) { var1 = 0; }"}, 203 {"", "for (var1 of [1, 2]) { var1 = 0; }"},
208 {1, "", "for (var var1 of [1, 2]) { var1 = 0; }"}, 204 {"", "for (var var1 of [1, 2]) { var1 = 0; }"},
209 {1, "", "for (let var1 of [1, 2]) { var1 = 0; }"}, 205 {"", "for (let var1 of [1, 2]) { var1 = 0; }"},
210 {1, "", "for (const var1 of [1, 2]) { var1 = 0; }"}, 206 {"", "for (const var1 of [1, 2]) { var1 = 0; }"},
211 207
212 {1, "", "for (var1 of [1, 2]) { function foo() { var1; } }"}, 208 {"", "for (var1 of [1, 2]) { function foo() { var1; } }"},
213 {1, "", "for (var var1 of [1, 2]) { function foo() { var1; } }"}, 209 {"", "for (var var1 of [1, 2]) { function foo() { var1; } }"},
214 {1, "", "for (let var1 of [1, 2]) { function foo() { var1; } }"}, 210 {"", "for (let var1 of [1, 2]) { function foo() { var1; } }"},
215 {1, "", "for (const var1 of [1, 2]) { function foo() { var1; } }"}, 211 {"", "for (const var1 of [1, 2]) { function foo() { var1; } }"},
216 212
217 {1, "", "for (var1 of [1, 2]) { function foo() { var1 = 0; } }"}, 213 {"", "for (var1 of [1, 2]) { function foo() { var1 = 0; } }"},
218 {1, "", "for (var var1 of [1, 2]) { function foo() { var1 = 0; } }"}, 214 {"", "for (var var1 of [1, 2]) { function foo() { var1 = 0; } }"},
219 {1, "", "for (let var1 of [1, 2]) { function foo() { var1 = 0; } }"}, 215 {"", "for (let var1 of [1, 2]) { function foo() { var1 = 0; } }"},
220 {1, "", "for (const var1 of [1, 2]) { function foo() { var1 = 0; } }"}, 216 {"", "for (const var1 of [1, 2]) { function foo() { var1 = 0; } }"},
221 217
222 // For in loops 218 // For in loops
223 {1, "", "for (var1 in {a: 6}) { }"}, 219 {"", "for (var1 in {a: 6}) { }"},
224 {1, "", "for (var var1 in {a: 6}) { }"}, 220 {"", "for (var var1 in {a: 6}) { }"},
225 {1, "", "for (let var1 in {a: 6}) { }"}, 221 {"", "for (let var1 in {a: 6}) { }"},
226 {1, "", "for (const var1 in {a: 6}) { }"}, 222 {"", "for (const var1 in {a: 6}) { }"},
227 223
228 {1, "", "for (var1 in {a: 6}) { var1; }"}, 224 {"", "for (var1 in {a: 6}) { var1; }"},
229 {1, "", "for (var var1 in {a: 6}) { var1; }"}, 225 {"", "for (var var1 in {a: 6}) { var1; }"},
230 {1, "", "for (let var1 in {a: 6}) { var1; }"}, 226 {"", "for (let var1 in {a: 6}) { var1; }"},
231 {1, "", "for (const var1 in {a: 6}) { var1; }"}, 227 {"", "for (const var1 in {a: 6}) { var1; }"},
232 228
233 {1, "", "for (var1 in {a: 6}) { var1 = 0; }"}, 229 {"", "for (var1 in {a: 6}) { var1 = 0; }"},
234 {1, "", "for (var var1 in {a: 6}) { var1 = 0; }"}, 230 {"", "for (var var1 in {a: 6}) { var1 = 0; }"},
235 {1, "", "for (let var1 in {a: 6}) { var1 = 0; }"}, 231 {"", "for (let var1 in {a: 6}) { var1 = 0; }"},
236 {1, "", "for (const var1 in {a: 6}) { var1 = 0; }"}, 232 {"", "for (const var1 in {a: 6}) { var1 = 0; }"},
237 233
238 {1, "", "for (var1 in {a: 6}) { function foo() { var1; } }"}, 234 {"", "for (var1 in {a: 6}) { function foo() { var1; } }"},
239 {1, "", "for (var var1 in {a: 6}) { function foo() { var1; } }"}, 235 {"", "for (var var1 in {a: 6}) { function foo() { var1; } }"},
240 {1, "", "for (let var1 in {a: 6}) { function foo() { var1; } }"}, 236 {"", "for (let var1 in {a: 6}) { function foo() { var1; } }"},
241 {1, "", "for (const var1 in {a: 6}) { function foo() { var1; } }"}, 237 {"", "for (const var1 in {a: 6}) { function foo() { var1; } }"},
242 238
243 {1, "", "for (var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 239 {"", "for (var1 in {a: 6}) { function foo() { var1 = 0; } }"},
244 {1, "", "for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 240 {"", "for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"},
245 {1, "", "for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 241 {"", "for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"},
246 {1, "", "for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 242 {"", "for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"},
247 243
248 {1, "", "for (var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 244 {"", "for (var1 in {a: 6}) { function foo() { var1 = 0; } }"},
249 {1, "", "for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 245 {"", "for (var var1 in {a: 6}) { function foo() { var1 = 0; } }"},
250 {1, "", "for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 246 {"", "for (let var1 in {a: 6}) { function foo() { var1 = 0; } }"},
251 {1, "", "for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"}, 247 {"", "for (const var1 in {a: 6}) { function foo() { var1 = 0; } }"},
252 248
253 // Loops without declarations 249 // Loops without declarations
254 {1, "", "var var1 = 0; for ( ; var1 < 2; ++var1) { }"}, 250 {"", "var var1 = 0; for ( ; var1 < 2; ++var1) { }"},
255 {1, "", 251 {"",
256 "var var1 = 0; for ( ; var1 < 2; ++var1) { function foo() { var1; } }"}, 252 "var var1 = 0; for ( ; var1 < 2; ++var1) { function foo() { var1; } }"},
257 {1, "", "var var1 = 0; for ( ; var1 > 2; ) { }"}, 253 {"", "var var1 = 0; for ( ; var1 > 2; ) { }"},
258 {1, "", "var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1; } }"}, 254 {"", "var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1; } }"},
259 {1, "", 255 {"",
260 "var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1 = 6; } }"}, 256 "var var1 = 0; for ( ; var1 > 2; ) { function foo() { var1 = 6; } }"},
261 257
262 {1, "", "var var1 = 0; for(var1; var1 < 2; ++var1) { }"}, 258 {"", "var var1 = 0; for(var1; var1 < 2; ++var1) { }"},
263 {1, "", 259 {"",
264 "var var1 = 0; for (var1; var1 < 2; ++var1) { function foo() { var1; } " 260 "var var1 = 0; for (var1; var1 < 2; ++var1) { function foo() { var1; } "
265 "}"}, 261 "}"},
266 {1, "", "var var1 = 0; for (var1; var1 > 2; ) { }"}, 262 {"", "var var1 = 0; for (var1; var1 > 2; ) { }"},
267 {1, "", 263 {"", "var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1; } }"},
268 "var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1; } }"}, 264 {"",
269 {1, "",
270 "var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1 = 6; } }"}, 265 "var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1 = 6; } }"},
271 266
272 // Sloppy block functions. 267 // Sloppy block functions.
273 {1, "", "if (true) { function f1() {} }"}, 268 {"", "if (true) { function f1() {} }"},
274 {1, "", "if (true) { function f1() {} function f1() {} }"}, 269 {"", "if (true) { function f1() {} function f1() {} }"},
275 {1, "", "if (true) { if (true) { function f1() {} } }"}, 270 {"", "if (true) { if (true) { function f1() {} } }"},
276 {1, "", "if (true) { if (true) { function f1() {} function f1() {} } }"}, 271 {"", "if (true) { if (true) { function f1() {} function f1() {} } }"},
277 {1, "", "if (true) { function f1() {} f1 = 3; }"}, 272 {"", "if (true) { function f1() {} f1 = 3; }"},
278 273
279 {1, "", "if (true) { function f1() {} function foo() { f1; } }"}, 274 {"", "if (true) { function f1() {} function foo() { f1; } }"},
280 {1, "", "if (true) { function f1() {} } function foo() { f1; }"}, 275 {"", "if (true) { function f1() {} } function foo() { f1; }"},
281 {1, "", 276 {"",
282 "if (true) { function f1() {} function f1() {} function foo() { f1; } " 277 "if (true) { function f1() {} function f1() {} function foo() { f1; } "
283 "}"}, 278 "}"},
284 {1, "", 279 {"",
285 "if (true) { function f1() {} function f1() {} } function foo() { f1; " 280 "if (true) { function f1() {} function f1() {} } function foo() { f1; "
286 "}"}, 281 "}"},
287 {1, "", 282 {"",
288 "if (true) { if (true) { function f1() {} } function foo() { f1; } }"}, 283 "if (true) { if (true) { function f1() {} } function foo() { f1; } }"},
289 {1, "", 284 {"",
290 "if (true) { if (true) { function f1() {} function f1() {} } function " 285 "if (true) { if (true) { function f1() {} function f1() {} } function "
291 "foo() { f1; } }"}, 286 "foo() { f1; } }"},
292 {1, "", "if (true) { function f1() {} f1 = 3; function foo() { f1; } }"}, 287 {"", "if (true) { function f1() {} f1 = 3; function foo() { f1; } }"},
293 {1, "", "if (true) { function f1() {} f1 = 3; } function foo() { f1; }"}, 288 {"", "if (true) { function f1() {} f1 = 3; } function foo() { f1; }"},
294 289
295 {1, "", "function inner2() { if (true) { function f1() {} } }"}, 290 {"", "function inner2() { if (true) { function f1() {} } }"},
296 {1, "", "function inner2() { if (true) { function f1() {} f1 = 3; } }"}, 291 {"", "function inner2() { if (true) { function f1() {} f1 = 3; } }"},
297 292
298 {1, "", "var f1 = 1; if (true) { function f1() {} }"}, 293 {"", "var f1 = 1; if (true) { function f1() {} }"},
299 {1, "", 294 {"", "var f1 = 1; if (true) { function f1() {} } function foo() { f1; }"},
300 "var f1 = 1; if (true) { function f1() {} } function foo() { f1; }"},
301 }; 295 };
302 296
303 for (unsigned i = 0; i < arraysize(inners); ++i) { 297 for (unsigned i = 0; i < arraysize(inners); ++i) {
304 // First compile with the lazy inner function and extract the scope data. 298 // First compile with the lazy inner function and extract the scope data.
305 const char* inner_function = lazy_inner; 299 const char* inner_function = lazy_inner;
306 int inner_function_len = Utf8LengthHelper(inner_function) - 4; 300 int inner_function_len = Utf8LengthHelper(inner_function) - 4;
307 301
308 int params_len = Utf8LengthHelper(inners[i].params); 302 int params_len = Utf8LengthHelper(inners[i].params);
309 int source_len = Utf8LengthHelper(inners[i].source); 303 int source_len = Utf8LengthHelper(inners[i].source);
310 int len = 304 int len =
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 CHECK(i::Compiler::Analyze(&eager_info)); 351 CHECK(i::Compiler::Analyze(&eager_info));
358 352
359 i::Scope* scope = 353 i::Scope* scope =
360 eager_info.literal()->scope()->inner_scope()->inner_scope(); 354 eager_info.literal()->scope()->inner_scope()->inner_scope();
361 DCHECK_NOT_NULL(scope); 355 DCHECK_NOT_NULL(scope);
362 DCHECK_NULL(scope->sibling()); 356 DCHECK_NULL(scope->sibling());
363 DCHECK(scope->is_function_scope()); 357 DCHECK(scope->is_function_scope());
364 358
365 size_t index = 0; 359 size_t index = 0;
366 i::ScopeTestHelper::CompareScopeToData( 360 i::ScopeTestHelper::CompareScopeToData(
367 scope, lazy_info.preparsed_scope_data(), index, 361 scope, lazy_info.preparsed_scope_data(), index);
368 inners[i].precise_maybe_assigned);
369 } 362 }
370 } 363 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.cc ('k') | test/cctest/scope-test-helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698