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 tagged template #6146

Closed
hyf0 opened this issue Oct 14, 2022 · 1 comment · Fixed by #6165
Closed

Wrong simplified expression in tagged template #6146

hyf0 opened this issue Oct 14, 2022 · 1 comment · Fixed by #6165
Assignees
Labels
Milestone

Comments

@hyf0
Copy link
Contributor

hyf0 commented Oct 14, 2022

Describe the bug

I'm using crates/swc_ecma_transforms_optimization/src/simplify/expr/mod.rs#expr_simplifier and found this bug.

Using Compress option will reproduce the bug in the playground, but I'm not sure what expr_simplifier is used in the playground.

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

Input code

let o = {
	f() {
		assert.ok(this !== o);
	}
};
(1, o.f)``;

Config

No response

Playground link

https://play.swc.rs/?version=1.3.7&code=H4sIAAAAAAAAA8tJLVHIV7BVqObiTNPQBFGcicXFqUUlevnZGiUZmcUKira2Cvma1lyctVy11lwahjoK%2BXppmgkJ1lwABzEzUjwAAAA%3D&config=H4sIAAAAAAAAA22TQZLjIAxF7%2BJ1FjO97APMrs9AERAOaUAuJNJxpXL3EY4NcdI76%2FlLiC9xG85khs%2FbMOlMkOsXzYn1dfgcwERNJvuJh4PIBDkdCO6HgXUegauEPv58%2FJXfAZFgFRyG6JN3cy1mME4ZiOq3JJUIianpdM74IyHnItERMYBOb7HSpHxiGCH3VIMh6IlAXXRuGfU0nT1h2qHCYNWUcXqiyXr2mKTYxixoqwxaaMBnMOwv0CVSQySJpLHWyQItHMs4VgMfSrjoUDS3WnBdbJATW94JPbFyJdEL2nX6QI9LrirvVAYuOW2aM%2Fq08%2BEbQPoMmijpCD1z4U7msFe6X1Q%2BORkiz43KhHtXCUa5nPLetRvWriGz725lsMVAvaHpxVe4uxB5CwqcE7dbMv14NqdejOcJ0LVQXNOuz%2BARqm2f9rSuwBv8J13x8zhWHjWfXhnN8YjhrUQEPqF9w2IE4yvMsr3X6ZWWZEFsBvv0o1AN25rK8BlVqK9t81kWQnLUGPDY1lceZdRpbGt5rwBtqeC2mCevVYyImM403PsT3XaKvlb1Uu0%2FcmhO6BcEAAA%3D

Expected behavior

(true && o.f)``; should simplify to (o.f)``

Actual behavior

(true && o.f)``; is simplify to o.f`` .

Version

1.3.7

Additional context

Esbuild also has the problem: evanw/esbuild#2610

@hyf0 hyf0 added the C-bug label Oct 14, 2022
@kdy1 kdy1 added this to the Planned milestone Oct 14, 2022
@kdy1 kdy1 self-assigned this Oct 14, 2022
kdy1 added a commit that referenced this issue Oct 15, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.9 Oct 17, 2022
@swc-bot
Copy link
Collaborator

swc-bot commented Nov 16, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants