simplify produces an incorrect result
See original GitHub issueDescribe the bug
Incorrect optimization.
To Reproduce
Minimal code to reproduce the bug
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,
function draw() {
const {
canvas,
currentLayout: layout
} = this;
canvas.width += 2 * CANVAS_PADDING, canvas.height += 2 * CANVAS_PADDING;
}
Expected Output
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
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Simplify quick-fix produces incorrect result when if condition ...
Simplify quick-fix produces incorrect result when if condition contains init statement. Subtask of 1. Subtask of 1 issue (1 unresolved).
Read more >Why is this simplification wrong? - Mathematics Stack Exchange
It's true that z/z=1 (if z≠0), but you don't have z/z in your expression.
Read more >Answer Explanations for the 2021-22 ACT Math Test - Piqosity
This would simplify the equation to 10 + 3(12 ÷(3⋅2)) ... volunteers who received an incorrect result from the Sam77 test are 25...
Read more >Solving Radical Equations
FALSE ! TRUE! Now check both solutions by substituting them into the original equation. Since x = −6 produces a false statement, it...
Read more >Common Mistakes
Cancelling incorrectly. When solving algebraic equations or simplifying rational expressions (polynomial fractions), students often try to "cancel" items to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My build process is webpack. I am using this minifier as a preset in the babel-loader… so, not really. Anyways, this has accidentally hijacked the original issue and I have found to be unrelated. (Which is why I updated my comment from two days ago) I originally thought this was related to the original issue, but I believe is intended behavior (the no-space between return and the quote)
Can your build process substitute
typeof define === "function"
withtrue
before you minify? This will also allow the minifier to remove unnecessary branches/conditionals.