Commit 3f06291b authored by arv's avatar arv Committed by Commit bot

[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}
parent ec542dea
......@@ -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."],
......
......@@ -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,
......
......@@ -71,6 +71,11 @@
class C extends Math.abs {}
}, TypeError);
delete Math.abs.prototype;
assertThrows(function() {
function* g() {}
class C extends g {}
}, TypeError);
})();
......
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