forked from facebookarchive/prepack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't error calling possibly non-functions in pure functions
As outlined in facebookarchive#1264 we know that it is safe to throw in an pure function since then the return value will be ignored and therefore its state doesn't matter. The only time it matters, is if there is a try/catch around it which we already warn about. This means that we don't have to error when calling a non-function. I also plan to add more of these cases like this. So I took the liberty to also move this category of tests into a separate folder.
- Loading branch information
1 parent
9949c16
commit 21bd845
Showing
6 changed files
with
43 additions
and
4 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
File renamed without changes.
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,26 @@ | ||
// additional functions | ||
// abstract effects | ||
|
||
let obj = global.__abstract ? __abstract('object', '({foo: function() { return 1; }})') : {foo: function() { return 1; }}; | ||
if (global.__makeSimple) { | ||
__makeSimple(obj); | ||
} | ||
let condition = global.__abstract ? __abstract('boolean', 'true') : true; | ||
|
||
function additional1() { | ||
return obj.foo(); | ||
} | ||
|
||
function additional2() { | ||
function fn() { | ||
return 5; | ||
} | ||
let fnOrString = condition ? fn : 'string'; | ||
return fnOrString(); | ||
} | ||
|
||
inspect = function() { | ||
let ret1 = additional1(); | ||
let ret2 = additional2(); | ||
return ret1 + ret2; | ||
} |