Skip to content

Inconsistency with mangling of reserved keywords #1152

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

Closed
glennsl opened this issue Feb 2, 2017 · 1 comment
Closed

Inconsistency with mangling of reserved keywords #1152

glennsl opened this issue Feb 2, 2017 · 1 comment

Comments

@glennsl
Copy link
Contributor

glennsl commented Feb 2, 2017

This came up when trying to import an es6 module, where the natural way of doing it breaks due to mangling of the reserved keyword default:

external foo': t = "default" [@@bs.module "some-es6-mod"];
let foo = foo';

is compiled into:

var SomeEs6Mod = require("some-es6-mod");
var foo = SomeEs6Mod.$$default;
exports.foo = foo;

This, on the other hand, works:

external foo': Js.t {. default: t } = "some-es6-mod" [@@bs.module];
let foo = foo'##default;

which compiles into:

var Foo$prime = require("some-es6-mod");
var foo = Foo$prime.default;
exports.foo = foo;

As I've been told, the latter case works because in Js.t, anything goes. But these two cases are functionally equivalent, and in the former case the reserved keyword is quoted, not even able to be used as an identifier. This makes the (non-)mangling rules rather counter-intuitive as well as inconsistent.

@bobzhang
Copy link
Member

bobzhang commented Mar 8, 2017

close as a duplication of #1151

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

No branches or pull requests

2 participants