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}
This commit is contained in:
arv 2015-02-26 10:36:59 -08:00 committed by Commit bot
parent 250dd1ed5a
commit 392b591e0c
4 changed files with 71 additions and 6 deletions

View File

@ -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,

View File

@ -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);
})();

View File

@ -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);
})();

View File

@ -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();
})();