Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid invalid code when "else" branch is simplified (#3421)
* Make sure there is always whitespace between "else" and the subsequent statement to avoid invalid code when the alternate branch is simplified. * Fix comment
- Loading branch information
1 parent
1e6284f
commit 85c54ee
Showing
3 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/function/samples/if-statement-insert-whitespace/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
description: 'inserts necessary white-space when simplifying if-statements (#3419)', | ||
options: { | ||
external: 'external' | ||
}, | ||
context: { | ||
require(required) { | ||
return false; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let works = false; | ||
const makeItWork = () => works = true; | ||
|
||
import value from 'external'; | ||
|
||
if (value) {} else"production"!=="local"?makeItWork():void 0; | ||
|
||
assert.ok(works); |