Commit 392b591e authored by arv's avatar arv Committed by Commit bot

Fix issue with class name TDZ in computed property names

BUG=v8:3923
LOG=N
R=marja,rossberg

Review URL: https://codereview.chromium.org/961823002

Cr-Commit-Position: refs/heads/master@{#26892}
parent 250dd1ed
......@@ -4118,7 +4118,6 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
bool has_seen_constructor = false;
Expect(Token::LBRACE, CHECK_OK);
int body_beg_pos = scanner()->location().beg_pos;
const bool has_extends = extends != nullptr;
while (peek() != Token::RBRACE) {
......@@ -4159,7 +4158,7 @@ ClassLiteral* Parser::ParseClassLiteral(const AstRawString* name,
if (name != NULL) {
DCHECK_NOT_NULL(proxy);
DCHECK_NOT_NULL(block_scope);
proxy->var()->set_initializer_position(body_beg_pos);
proxy->var()->set_initializer_position(end_pos);
}
return factory()->NewClassLiteral(name, block_scope, proxy, extends,
......
......@@ -388,3 +388,45 @@ function assertIteratorResult(value, done, result) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(undefined, true, iter.next());
})();
(function TestExceptionInName() {
function MyError() {};
function throwMyError() {
throw new MyError();
}
assertThrows(function() {
class C {
[throwMyError()]() {}
}
}, MyError);
assertThrows(function() {
class C {
get [throwMyError()]() { return 42; }
}
}, MyError);
assertThrows(function() {
class C {
set [throwMyError()](_) { }
}
}, MyError);
})();
(function TestTdzName() {
assertThrows(function() {
class C {
[C]() {}
}
}, ReferenceError);
assertThrows(function() {
class C {
get [C]() { return 42; }
}
}, ReferenceError);
assertThrows(function() {
class C {
set [C](_) { }
}
}, ReferenceError);
})();
......@@ -277,3 +277,26 @@ function ID(x) {
assertEquals('X', object.x);
assertEquals(proto, Object.getPrototypeOf(object));
})();
(function TestExceptionInName() {
function MyError() {};
function throwMyError() {
throw new MyError();
}
assertThrows(function() {
var o = {
[throwMyError()]: 42
};
}, MyError);
assertThrows(function() {
var o = {
get [throwMyError()]() { return 42; }
};
}, MyError);
assertThrows(function() {
var o = {
set [throwMyError()](_) { }
};
}, MyError);
})();
......@@ -180,9 +180,10 @@ function assertThrowsHelper(code, error) {
eval("var7;");
})();
class C1 { constructor() { C1; } }; new C1();
let C2 = class C3 { constructor() { C3; } }; new C2();
// https://code.google.com/p/v8/issues/detail?id=3927
// class C1 { constructor() { C1; } }; new C1();
// let C2 = class C3 { constructor() { C3; } }; new C2();
class C4 { method() { C4; method; } }; new C4();
let C5 = class C6 { method() { C6; method; } }; new C5();
// class C4 { method() { C4; method; } }; new C4();
// let C5 = class C6 { method() { C6; method; } }; new C5();
})();
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