Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure logical expressions always check the left argument for side…
…-effects (#3438)
- Loading branch information
1 parent
2895a55
commit 5a45128
Showing
3 changed files
with
26 additions
and
3 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
3 changes: 3 additions & 0 deletions
3
test/function/samples/reassigned-return-expression/_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,3 @@ | ||
module.exports = { | ||
description: 'does not bind return expressions before assignments are bound (#3382)' | ||
}; |
17 changes: 17 additions & 0 deletions
17
test/function/samples/reassigned-return-expression/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,17 @@ | ||
function getIcon() { | ||
var icon = undefined; | ||
icon = { code: true }; | ||
return icon; | ||
} | ||
|
||
function main() { | ||
var a = getIcon() || { | ||
code: undefined | ||
}; | ||
if (!a.code) { | ||
return 'broken'; | ||
} | ||
return 'works'; | ||
} | ||
|
||
assert.strictEqual(main(), 'works'); |