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

Fix/issue 1124 #1279

Merged
merged 3 commits into from Nov 1, 2022
Merged

Fix/issue 1124 #1279

merged 3 commits into from Nov 1, 2022

Conversation

Solo-steven
Copy link
Contributor

@Solo-steven Solo-steven commented Oct 23, 2022

fix issue #1124


I fix this issue by adding a context to determine if the current expression is under the class field. if is true, then it is legal to use an in operator with privatename token. if is false. parse would throw an error.

And I find a problem is that terser allow parse function to accept private field even out of class field, which should be a syntax error. so I add a condition to subscripts function to determine if the current subscript is under class feild. if is true, parse would parse it correctly, if is false it would throw an error.

To pass the test, I delete one test from /compress/class-properity which allows parse function to accept private fields even out of class field, which should be a syntax error.

I also add a condition to binary expression, because even class field can use in operation with privatename, other expressions like add can’t use privatename without subscript. for example :

// in class field
 #p in this // pass
 this.#p + 10 // pass
 input.#p + 10 // pass, input can be a param
 #p + 10 // error

lib/parse.js Outdated Show resolved Hide resolved
lib/parse.js Outdated Show resolved Hide resolved
lib/parse.js Outdated Show resolved Hide resolved
lib/parse.js Outdated Show resolved Hide resolved
lib/parse.js Outdated Show resolved Hide resolved
@fabiosantoscode fabiosantoscode merged commit 144609a into terser:master Nov 1, 2022
8 checks passed
@fabiosantoscode
Copy link
Collaborator

Thank you very much!

@Solo-steven
Copy link
Contributor Author

@fabiosantoscode Thanks for merging and reviewing, and apologies for my bad English.

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

Successfully merging this pull request may close these issues.

None yet

2 participants