Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class name not being inherited in an anonymous class since 12.16.0 #31830

Closed
YoannMa opened this issue Feb 17, 2020 · 5 comments
Closed

class name not being inherited in an anonymous class since 12.16.0 #31830

YoannMa opened this issue Feb 17, 2020 · 5 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@YoannMa
Copy link

YoannMa commented Feb 17, 2020

  • Version: v12.16.0
  • Platform: Linux yoann-MS-7C09 4.15.0-74-generic # 84-Ubuntu SMP Thu Dec 19 08:06:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem:

What steps will reproduce the bug?

Running this script on v12.16.0 will return false when before it was returning true

'use strict';

const extend = (Model) => class extends Model {}

class FOO {};

const BAR = extend(FOO);

console.log(BAR.name === 'FOO');

How often does it reproduce? Is there a required condition?

Always since v12.16.0

What is the expected behavior?

I do not know which one is the expected behavior.

What do you see instead?

  • v12.15.0 : true
  • v12.16.0 : false
  • v13.8.0 : false

Additional information

@vdeturckheim
Copy link
Member

With jsvu I managed to find this on v8. It seems it appeared between v8-7.8.185 and v8-7.8.186.

I am not sure if this is a bug fixed there.

@vdeturckheim vdeturckheim added the v8 engine Issues and PRs related to the V8 dependency. label Feb 17, 2020
@targos
Copy link
Member

targos commented Feb 17, 2020

Could you check what spidermonkey and jsc do?

@vdeturckheim
Copy link
Member

Sure, good point:

  • sm-latest: BAR.name !== 'FOO'
  • jsc-latest: BAR.name !== 'FOO'

This looks indeed like a bugfix in v8 (or at least an alignment on other engines)

@bnoordhuis
Copy link
Member

This is indeed a spec conformance thing: the .name property of an anonymous class should be the empty string. A more minimal test case is this:

// should be '', is 'Object' with older node versions
(class extends Object {}).name

The V8 change that's responsible was reverted because of fuzzer issues and hasn't been relanded, AFAICT.

We should probably close this because it's ultimately not a Node.js issue but cc @nodejs/v8 just in case.

@vdeturckheim
Copy link
Member

Thanks for the clarification @bnoordhuis !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

4 participants