Skip to content

helper.instanceof does not cast [Symbol.hasInstance] call to boolean #10196

Description

@JLHwung

Bug Report

Current Behavior
When the object has specified a [Symbol.hasInstance] method, helpers.instanceof does not cast the return result to boolean

Input Code

  • REPL or Repo link if applicable: The REPL can not load @babel/[email protected] due to a 404 error.
var qux = {};
qux[Symbol.hasInstance]= function () { return NaN };
helpers.instanceof(0, qux);
// actual: returns NaN;
// expected: returns false;

Expected behavior/code
Per 12.10.4Runtime Semantics: InstanceofOperator ( V, target ), we should cast the return result to boolean.

Environment

  • Babel version(s): 7.5.0
  • Node/npm version: npm 5
  • OS: macOS 10.14.5
  • Monorepo: N.A.
  • How you are using Babel: Reading the source code

Possible Solution
An PR is on the way.

Additional context/Screenshots
N.A.

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions