Compose subsequent effects with currently applied affects (#2271)

Summary:
Release note: none

This fixes a problem reported as a comment in PR #2258.

The underlying problem was that Realm.evaluateForEffects would just append the normal effects, captured since the last non complete join, into the saved partially normal completion that becomes the result of the returned Effects. This is not quite right because applying the resulting Effects should restore the complete set of normal effects that were in force when evaluateForEffects completed.
Pull Request resolved: https://github.com/facebook/prepack/pull/2271

Differential Revision: D8870763

Pulled By: hermanventer

fbshipit-source-id: 027924f2b250174393c60d90c2feefdb5a55eec3
This commit is contained in:
Herman Venter 2018-07-16 18:17:42 -07:00 committed by Facebook Github Bot
parent bad3985f54
commit 2dc8607269
3 changed files with 21 additions and 1 deletions

View File

@ -306,7 +306,7 @@ function callNativeFunctionValue(
mightBecomeAnObject(contextVal)
);
let completion = f.callCallback(
// this is to get around Flow not understand the above invariant
// this is to get around Flow not understanding the above invariant
((contextVal: any): AbstractObjectValue | ObjectValue | NullValue | UndefinedValue),
argumentsList,
env.environmentRecord.$NewTarget

View File

@ -877,6 +877,7 @@ export class Realm {
this.stopEffectCaptureAndUndoEffects(c);
Join.updatePossiblyNormalCompletionWithSubsequentEffects(this, c, subsequentEffects);
this.savedCompletion = undefined;
this.applyEffects(subsequentEffects, "subsequentEffects", true);
}
invariant(this.generator !== undefined);

View File

@ -0,0 +1,19 @@
function fn2(shouldError) {
if (shouldError) {
throw new Error("Error");
}
return {
thisValueShouldExist: true,
};
}
function fn(shouldError) {
var a = Object.assign({}, fn2(shouldError));
return a.thisValueShouldExist;
}
this.__optimize && __optimize(fn);
inspect = function() {
return fn(false);
};