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

Hygiene broken in template literals that use interpolation #744

Open
kevin-dp opened this issue Oct 2, 2017 · 1 comment
Open

Hygiene broken in template literals that use interpolation #744

kevin-dp opened this issue Oct 2, 2017 · 1 comment

Comments

@kevin-dp
Copy link

kevin-dp commented Oct 2, 2017

Assume a regular JS file with no macros involved at all:

var test = { someField: 10 };
console.log(`test.someField = ${test.someField}`);

One would expect that the compilation of regular JS code containing no macros yields equivalent code.
However, this is the resulting code after compilation:

var test_0 = { someField: 10 };
console.log(`test.someField = ${test.someField}`);

Notice how the variable test has been renamed to test_0 for hygiene, but test in the interpolation within the template literal is unchanged.

This bug does not occur when avoiding template literals and writing it as
console.log('test.someField = ' + test.someField);

@shaunlebron
Copy link

this bit me today. is it possible to disable hygiene to prevent renaming? this would be useful for simple cases where we are not inserting any new variables.

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

3 participants