Commit 44a381ad authored by marja's avatar marja Committed by Commit bot

[parser] Skipping inner funcs: produce the same scopes / variables for this expressions.

BUG=v8:5516
R=vogelheim@chromium.org

Review-Url: https://codereview.chromium.org/2683563002
Cr-Commit-Position: refs/heads/master@{#42983}
parent ef4e2ab7
......@@ -203,9 +203,10 @@ class PreParserExpression {
IsUseAsmField::encode(true));
}
static PreParserExpression This() {
static PreParserExpression This(ZoneList<VariableProxy*>* variables) {
return PreParserExpression(TypeField::encode(kExpression) |
ExpressionTypeField::encode(kThisExpression));
ExpressionTypeField::encode(kThisExpression),
variables);
}
static PreParserExpression ThisProperty() {
......@@ -1494,7 +1495,19 @@ class PreParser : public ParserBase<PreParser> {
}
V8_INLINE PreParserExpression ThisExpression(int pos = kNoSourcePosition) {
return PreParserExpression::This();
ZoneList<VariableProxy*>* variables = nullptr;
if (track_unresolved_variables_) {
AstNodeFactory factory(ast_value_factory());
// Setting the Zone is necessary because zone_ might be the temp Zone, and
// AstValueFactory doesn't know about it.
factory.set_zone(zone());
VariableProxy* proxy = scope()->NewUnresolved(
&factory, ast_value_factory()->this_string(), pos, THIS_VARIABLE);
variables = new (zone()) ZoneList<VariableProxy*>(1, zone());
variables->Add(proxy, zone());
}
return PreParserExpression::This(variables);
}
V8_INLINE PreParserExpression NewSuperPropertyReference(int pos) {
......
......@@ -9258,12 +9258,19 @@ TEST(PreParserScopeAnalysis) {
{"", "var var1; if (true) { const var1 = 0; }"},
{"", "const var1 = 0; if (true) { const var1 = 0; }"},
// Variable called "arguments"
// Arguments and this.
{"", "arguments;"},
{"", "arguments = 5;"},
{"", "if (true) { arguments; }"},
{"", "if (true) { arguments = 5; }"},
{"", "function f() { arguments; }"},
{"", "function f() { arguments = 5; }"},
{"", "this;"},
{"", "if (true) { this; }"},
{"", "function f() { this; }"},
// Variable called "arguments"
{"", "var arguments;"},
{"", "var arguments; arguments = 5;"},
{"", "if (true) { var arguments; }"},
......@@ -9435,9 +9442,6 @@ TEST(PreParserScopeAnalysis) {
{"",
"var var1 = 0; for (var1; var1 > 2; ) { function foo() { var1 = 6; } }"},
// FIXME(marja): Add test cases for special variables (this, arguments
// etc) referred to in the for loop conditions.
// Sloppy block functions.
{"", "if (true) { function f1() {} }"},
{"", "if (true) { function f1() {} function f1() {} }"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment