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

[Bug]: IIFE that returns optional call results in syntax error #1298

Closed
p51lee opened this issue Nov 7, 2022 · 1 comment
Closed

[Bug]: IIFE that returns optional call results in syntax error #1298

p51lee opened this issue Nov 7, 2022 · 1 comment
Labels

Comments

@p51lee
Copy link

p51lee commented Nov 7, 2022

Bug report

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

$ terser -V
terser 5.15.1

Complete CLI command or minify() options used
I turned off the unsafe option.

$ terser input.js -c unsafe=false

terser input

-- ( x => 0 ?. ( ) ) ( ) . x ;

terser output or error

--0?.().x;

Expected result
Input code throws TypeError:

$ node input.js
input.js:1
-- ( x => 0 ?. ( ) ) ( ) . x ;
               ^

TypeError: 0 is not a function
    at input.js:1:16
    at Object.<anonymous> (/Users/p51lee/dev/javascript-test/input.js:1:22)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

but output code throws SyntaxError:

$ terser input.js -c unsafe=false | node
[stdin]:1
--0?.().x;
  ^^^^^^^

SyntaxError: Invalid left-hand side expression in prefix operation
    at new Script (node:vm:100:7)
    at createScript (node:vm:265:10)
    at Object.runInThisContext (node:vm:313:10)
    at node:internal/process/execution:79:19
    at [stdin]-wrapper:6:22
    at evalScript (node:internal/process/execution:78:60)
    at node:internal/main/eval_stdin:30:5
    at Socket.<anonymous> (node:internal/process/execution:195:5)
    at Socket.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)

Node.js v18.11.0
@fabiosantoscode
Copy link
Collaborator

Closed as part of #1374

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