Node: Possible bug: instanceof evaluates to true in Node 4 but not Node 6

Created on 7 Jul 2016  路  11Comments  路  Source: nodejs/node

  • Version: 6.3.0:
  • Platform: Darwin 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64:
  • Subsystem:

In Node 4, the last statement evaluates to true, but in Node 6 it evaluates to false. Is this a bug?

F = () => {};
F.prototype = {};
Object.create(F.prototype) instanceof F;

Another user verified the behavior on their Windows system: http://stackoverflow.com/questions/38253656/instanceof-evaluates-to-true-in-node-4-but-not-node-6

V8 Engine

Most helpful comment

Yup, works as expected in 6.3.1. Thanks for taking care of this!

All 11 comments

/cc @nodejs/v8

I should note that it returns true in master.

Looks like a bug to me. v7.0.0-pre (V8 5.1) returns true, which is what I would expect.

All Node.js version 6.x releases that I tried returned the surprising false including 6.0.0.

Version 5.12.0 returned true.

So this would seem to be either a bug in the V8 that shipped with Node.js v6.x or (less likely, I imagine, but still possible) a bug in a patch that we are only floating in v6.x. (I'm not even sure there are any that are in 6.x but not in 5.x or current master.)

In d8 version 5.0.71.54 it returns false. So not related to floating patches.

This is the commit that fixed it: https://codereview.chromium.org/1810953002/

The patch applies clean on v6.x and fixes this issue. Do we want to float the patch on v6.x or just wait because it's fixed in V8 5.1 anyways?

/cc @nodejs/lts Not strictly an LTS question/issue, but I suspect they'll have an opinion on @fhinkel's question.

Another patch was recently back ported to 5.1 by @bnoordhuis

There is going to be a discussion about maintaining lts release streams directly from V8 to avoid floating patches. Aiming for 6 am estwif anyone wants to join.

I'm all for back-porting patches that apply cleanly or with minimal wedging.

@fhinkel I see you've done the work already. If you file a pull request and cc me, I'll review it.

Fixed in https://github.com/nodejs/node/pull/7638.

Can we close this?

Yup, works as expected in 6.3.1. Thanks for taking care of this!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fanjunzhi picture fanjunzhi  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments

loretoparisi picture loretoparisi  路  3Comments

dfahlander picture dfahlander  路  3Comments

addaleax picture addaleax  路  3Comments