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

Miscompilation when Promise is used as a constructor and as an object #5

Open
quasicomputational opened this issue Feb 23, 2019 · 0 comments

Comments

@quasicomputational
Copy link

With this input:

Promise.resolve("hi");

new Promise((resolve) => resolve("OK"));

this plugin produces output like this:

"use strict";

var _bluebird = _interopRequireDefault(require("bluebird"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(0, _bluebird.resolve)("hi");
new _bluebird.default(resolve => resolve("OK"));

which, rather predictably, fails at runtime - one access or the other is bound to be wrong! And consider how Promise.default would be compiled.

Fixing this will basically amount to reverting 4c87f96 (PR incoming), but I don't have an understanding of why that change was made in the first place. Maybe Babel's changed in the interim and whatever problem was being solved isn't relevant any more?

quasicomputational added a commit to quasicomputational/babel-plugin-transform-promise-to-bluebird that referenced this issue Feb 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant