babel / babel/minify

simplify produces an incorrect result

Open
#905 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
4.4k
Forks
217
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

Incorrect optimization.

**To Reproduce**

Minimal code to reproduce the bug

```js
function draw () {
const {canvas, currentLayout: layout} = this;

canvas.width = layout.canvas.width + 2 * CANVAS_PADDING;
canvas.height = layout.canvas.height + 2 * CANVAS_PADDING;
}
```

**Actual Output**

If there is no Error thrown,

```js
function draw() {
const {
canvas,
currentLayout: layout
} = this;

canvas.width += 2 * CANVAS_PADDING, canvas.height += 2 * CANVAS_PADDING;
}
```

**Expected Output**

```js
function draw() {
const {
canvas,
currentLayout: layout
} = this;

canvas.width = layout.canvas.width + 2 * CANVAS_PADDING, canvas.height = layout.canvas.width + 2 * CANVAS_PADDING;
}
```

**Configuration**

How are you using babel-minify? `babel --plugins minify-simplify test.js`

babel-minify version: `0.4.3`

babel version : `7.1.0`

babel-minify-config: none
babelrc: none

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.