[es6] Class extends may not be a generator function

BUG=v8:4009
LOG=N
R=dslomov@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#28016}
This commit is contained in:
arv 2015-04-22 09:07:34 -07:00 committed by Commit bot
parent ec542dea6b
commit 3f06291b3a
3 changed files with 12 additions and 0 deletions

View File

@ -157,6 +157,7 @@ var kMessages = {
duplicate_export: ["Duplicate export of '", "%0", "'"],
unexpected_super: ["'super' keyword unexpected here"],
extends_value_not_a_function: ["Class extends value ", "%0", " is not a function or null"],
extends_value_generator: ["Class extends value ", "%0", " may not be a generator function"],
prototype_parent_not_an_object: ["Class extends value does not have valid prototype property ", "%0"],
duplicate_constructor: ["A class may only have one constructor"],
super_constructor_call: ["A 'super' constructor call may only appear as the first statement of a function, and its arguments may not access 'this'. Other forms are not yet supported."],

View File

@ -119,6 +119,12 @@ RUNTIME_FUNCTION(Runtime_DefineClass) {
if (super_class->IsNull()) {
prototype_parent = isolate->factory()->null_value();
} else if (super_class->IsSpecFunction()) {
if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) {
Handle<Object> args[1] = {super_class};
THROW_NEW_ERROR_RETURN_FAILURE(
isolate,
NewTypeError("extends_value_generator", HandleVector(args, 1)));
}
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, prototype_parent,
Runtime::GetObjectProperty(isolate, super_class,

View File

@ -71,6 +71,11 @@
class C extends Math.abs {}
}, TypeError);
delete Math.abs.prototype;
assertThrows(function() {
function* g() {}
class C extends g {}
}, TypeError);
})();