Commit 477b75f1 authored by arv@chromium.org's avatar arv@chromium.org

Arrow functions: Cleanup handling of the prototype property

The old code did not work correctly in case of optimizations. I
found this out when implementing concise methods and we now plumb
through the function kind so we know what kind of Map to create for
the function.

BUG=v8:2700
LOG=y
R=rossberg@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23920 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent cfcad1d3
......@@ -559,7 +559,7 @@ class Context: public FixedArray {
: STRICT_GENERATOR_FUNCTION_MAP_INDEX;
}
if (IsConciseMethod(kind)) {
if (IsArrowFunction(kind) || IsConciseMethod(kind)) {
return strict_mode == SLOPPY
? SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
: STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
......
......@@ -1237,10 +1237,6 @@ void Factory::InitializeFunction(Handle<JSFunction> function,
function->set_prototype_or_initial_map(*the_hole_value());
function->set_literals_or_bindings(*empty_fixed_array());
function->set_next_function_link(*undefined_value());
// TODO(arv): This does not look correct. We need to make sure we use
// a Map that has no prototype property.
if (info->is_arrow()) function->RemovePrototype();
}
......
......@@ -8,7 +8,8 @@
// "new" operator on them.
assertEquals("function", typeof (() => {}));
assertEquals(Function.prototype, Object.getPrototypeOf(() => {}));
assertThrows("new (() => {})", TypeError);
assertThrows(function() { new (() => {}); }, TypeError);
assertFalse("prototype" in (() => {}));
// Check the different syntax variations
assertEquals(1, (() => 1)());
......
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