google / google/closure-compiler

Feature request: Cross module code motion should move pure calls

Open
#2,316 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Create two modules:

```js
// module 1
/** @constructor */ function Point(x, y) { this.x = x; this.y = y; }
var ZERO = new Point(0, 0);
```

```js
// module 2
alert(ZERO)
```

It would be nice if cross-module code motion could figure out that `Point` is "pure" and so everything can be moved into the second module.

http://closure-compiler-debugger.appspot.com/#input0%3D%252F**%2520%2540constructor%2520*%252F%2520function%2520Point(x%252C%2520y)%2520%257B%2520this.x%2520%253D%2520x%253B%2520this.y%2520%253D%2520y%253B%2520%257D%250Avar%2520ZERO%2520%253D%2520new%2520Point(0%252C%25200)%253B%26input1%3Dalert(ZERO)%26conformanceConfig%26externs%26refasterjs-template%26includeDefaultExterns%3D1%26CHECK_SYMBOLS%3D1%26MISSING_PROPERTIES%3D1%26TRANSPILE%3D1%26CHECK_TYPES%3D1%26COMPUTE_FUNCTION_SIDE_EFFECTS%3D1%26MARK_NO_SIDE_EFFECT_CALLS%3D1%26CROSS_MODULE_CODE_MOTION%3D1%26CROSS_MODULE_METHOD_MOTION%3D1%26CLOSURE_PASS%3D1%26PRESERVE_TYPE_ANNOTATIONS%3D1%26PRETTY_PRINT%3D1

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.