Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing spaces in certain statements and expressions to avoid inv…
…alid code (#3173) * Add missing spaces in certain statements and expressions to avoid invalid syntax * Improve coverage
- Loading branch information
1 parent
121a7f4
commit 91cb8f0
Showing
10 changed files
with
63 additions
and
19 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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
module.exports = { | ||
description: | ||
'await statements should never be dropped if a function has other side-effects (#1584)', | ||
options: { output: { name: 'myBundle' } } | ||
'await statements should never be dropped if a function has other side-effects (#1584)' | ||
}; |
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
await operation(); | ||
|
||
await retainedOperation(); |
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ System.register([], function () { | |
|
||
await operation(); | ||
|
||
await retainedOperation(); | ||
|
||
} | ||
}; | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
await operation(); | ||
|
||
if (false) | ||
await treeshakenOperation(); | ||
if (false) await treeshakenOperation(); | ||
else await retainedOperation(); |
5 changes: 5 additions & 0 deletions
5
test/function/samples/missing-spaces-after-simplification/_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,5 @@ | ||
module.exports = { | ||
description: | ||
'handle situations where the simplification of an expression can lead to issues due to missing white-space', | ||
options: { treeshake: { tryCatchDeoptimization: false } } | ||
}; |
28 changes: 28 additions & 0 deletions
28
test/function/samples/missing-spaces-after-simplification/main.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,28 @@ | ||
let result = ''; | ||
|
||
const a = { a: true }; | ||
for (const key in!0?a:a) result += key; | ||
|
||
const b = ['b']; | ||
for (const value of!0?b:b) result += value; | ||
|
||
const c = 'c'; | ||
function testReturn() { | ||
return!0?c:c; | ||
} | ||
result += testReturn(); | ||
|
||
const d = 'd'; | ||
function* testYield() { | ||
yield!0?d:d; | ||
} | ||
for (const value of testYield()) result += value; | ||
|
||
const e = 'e'; | ||
try { | ||
throw!0?e:e; | ||
} catch (err) { | ||
result += err; | ||
} | ||
|
||
assert.strictEqual(result, 'abcde'); |