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

Wrong simplified expression in the tagged template #2610

Closed
hyf0 opened this issue Oct 14, 2022 · 0 comments
Closed

Wrong simplified expression in the tagged template #2610

hyf0 opened this issue Oct 14, 2022 · 0 comments

Comments

@hyf0
Copy link

hyf0 commented Oct 14, 2022

input

const assert = require('assert')
let o = {
	f() {
		assert.ok(this !== o);
	}
};
console.log('----');
(1, o.f)();
(1, o.f)``;
console.log('----');
(true && o.f)();
(true && o.f)``;
console.log('----');
(true ? o.f : false)();
(true ? o.f : false)``;

output

// project/index.ts
var o = {
  f() {
    assert.ok(this !== o);
  }
};
console.log("----");
(1, o.f)();
(1, o.f)``;
console.log("----");
(0, o.f)();
o.f``;
console.log("----");
(true ? o.f : false)();
(true ? o.f : false)``;

problem

(true && o.f)``; is simplify to o.f`` , which causes this pointing to a wrong object.

Playground link

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