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

with function parameter 'private' in ES5 script #1041

Closed
alexander-akait opened this issue Aug 2, 2021 · 1 comment
Closed

with function parameter 'private' in ES5 script #1041

alexander-akait opened this issue Aug 2, 2021 · 1 comment
Labels

Comments

@alexander-akait
Copy link

Bug report or Feature request?

Fails when function parameter has private name

webpack/webpack#13859

Version (complete output of terser -V or specific git commit)

latest (5.7.1)

Complete CLI command or minify() options used

terser input

const myMixin = function(private, public) {
  private.something = "some value";
}

terser output or error

ERROR in frag.min.js from Terser
Unexpected token: name (private) [webpack://./src/Cameras/cameraMixin.js:1,0][frag.min.js:1018,43]
    at js_error (./node_modules/terser/dist/bundle.min.js:550:11)
    at croak (./node_modules/terser/dist/bundle.min.js:1274:9)
    at token_error (./node_modules/terser/dist/bundle.min.js:1282:9)
    at unexpected (./node_modules/terser/dist/bundle.min.js:1288:9)
    at Object.add_parameter (./node_modules/terser/dist/bundle.min.js:1766:33)
    at binding_element (./node_modules/terser/dist/bundle.min.js:2023:29)
    at parameter (./node_modules/terser/dist/bundle.min.js:1830:17)
    at parameters (./node_modules/terser/dist/bundle.min.js:1804:25)
    at _function_body (./node_modules/terser/dist/bundle.min.js:2077:19)
    at function_ (./node_modules/terser/dist/bundle.min.js:1728:20)

Expected result

No errors

@fabiosantoscode
Copy link
Collaborator

This shouldn't crash indeed.

It's still technically correct though. The token private is a reserved word in strict mode.

If you run this in your browser (() => { 'use strict'; private })() you'll see an error about it.

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

No branches or pull requests

2 participants