google / google/closure-compiler

Add compiler pass that converts new+anonymous function to IIFE

Open
#3,221 5 comments 0 reactions 0 assignees View on GitHub
internal-issue-created triage-done
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Now compiler can't optimize constructions like:
```
new function() {
console.log(1);
};
```
As i know this is equal to:
```
(function() {
console.log(1);
return {};
})()
```
which can be simplified to:
```
console.log(1);
```

Is it possible to add similar pass to main optimization loop or update inlineFunctions pass to support it?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.