Commit f39665e3 authored by nikolaos's avatar nikolaos Committed by Commit bot

[parser] Fix bug with non-static name method/property

Without this patch, the tests on lines 410, 414, 418 and 422 in
function testNonStaticName of test/mjsunit/es6/function-name.js
would all fail.  The bug caused non-static "name" methods and
properties to be mistaken for static ones.

R=adamk@chromium.org, verwaest@chromium.org
BUG=
LOG=N

Review-Url: https://codereview.chromium.org/2567343004
Cr-Commit-Position: refs/heads/master@{#41692}
parent 576abe14
...@@ -2177,7 +2177,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition( ...@@ -2177,7 +2177,7 @@ ParserBase<Impl>::ParseClassPropertyDefinition(
is_computed_name, CHECK_OK_CUSTOM(EmptyClassLiteralProperty)); is_computed_name, CHECK_OK_CUSTOM(EmptyClassLiteralProperty));
} }
if (!*has_name_static_property && is_static && impl()->IsName(name)) { if (!*has_name_static_property && *is_static && impl()->IsName(name)) {
*has_name_static_property = true; *has_name_static_property = true;
} }
......
...@@ -386,3 +386,39 @@ ...@@ -386,3 +386,39 @@
class C { static name() { } static foo() { } } class C { static name() { } static foo() { } }
assertEquals(['length', 'prototype', 'name', 'foo'], Object.getOwnPropertyNames(C)); assertEquals(['length', 'prototype', 'name', 'foo'], Object.getOwnPropertyNames(C));
})(); })();
(function testStaticName() {
class C { static name() { return 42; } }
assertEquals(42, C.name());
assertEquals(undefined, new C().name);
class D { static get name() { return 17; } }
assertEquals(17, D.name);
assertEquals(undefined, new D().name);
var c = class { static name() { return 42; } }
assertEquals(42, c.name());
assertEquals(undefined, new c().name);
var d = class { static get name() { return 17; } }
assertEquals(17, d.name);
assertEquals(undefined, new d().name);
})();
(function testNonStaticName() {
class C { name() { return 42; } }
assertEquals('C', C.name);
assertEquals(42, new C().name());
class D { get name() { return 17; } }
assertEquals('D', D.name);
assertEquals(17, new D().name);
var c = class { name() { return 42; } }
assertEquals('c', c.name);
assertEquals(42, new c().name());
var d = class { get name() { return 17; } }
assertEquals('d', d.name);
assertEquals(17, new d().name);
})();
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