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

Incorrect `name` of `dynamic function` . #8952

Open
zhengxiaoyao0716 opened this Issue Oct 31, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@zhengxiaoyao0716

zhengxiaoyao0716 commented Oct 31, 2018

Bug Report

Current Behavior
A clear and concise description of the behavior.
({ [fn]: () => { } }).fn.name;, expected fn, got undefined.
image
image

Input Code

  • REPL or Repo link if applicable:
    REPL
({ ['fn']: () => { } }).fn.name;
({ [`fn`]: () => { } }).fn.name;

Expected behavior/code
A clear and concise description of what you expected to happen (or code).
image

Environment

  • Babel version(s): v6.26.0
    just use the online REPL of bablejs.io.

Possible Solution
This could work if babel compile the code above to that:

'use strict';

function _defineProperty(obj, key, value) { if (value instanceof Function) { Object.defineProperty(value, 'name', { value: key }); };  if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

_defineProperty({}, 'fn', function () {}).fn.name;
_defineProperty({}, 'fn', function () {}).fn.name;
@babel-bot

This comment has been minimized.

Collaborator

babel-bot commented Oct 31, 2018

Hey @zhengxiaoyao0716! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Member

nicolo-ribaudo commented Nov 4, 2018

This has been fixed in Babel 7: https://babeljs.io/repl/build/master#?babili=false&browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=BQbwBA2g5AZgdlAugLjMAlGAvAPjOAXzAPQDp5S4BDAWwFMBuAKFEgAN42U1Nd9jiZCtXoMgA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=true&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=es2015&prettier=false&targets=&version=7.1.2&envVersion=

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

_defineProperty({}, 'fn', function fn() {}).fn.name;
_defineProperty({}, "fn", function fn() {}).fn.name;
@zhengxiaoyao0716

This comment has been minimized.

zhengxiaoyao0716 commented Nov 5, 2018

image
image

I have tried it but still not work.

@nicolo-ribaudo nicolo-ribaudo reopened this Nov 5, 2018

@xtuc xtuc added the i: bug label Nov 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment