Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fix composed completion undo #2467

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,17 @@ export class Realm {
this.restoreBindings(result.modifiedBindings);
this.restoreProperties(result.modifiedProperties);
} else {
if (this.savedCompletion !== undefined) {
this.stopEffectCaptureAndUndoEffects(this.savedCompletion);
}
this.restoreBindings(this.modifiedBindings);
this.restoreProperties(this.modifiedProperties);
let completion = this.savedCompletion;
while (completion !== undefined) {
const { savedEffects } = completion;
if (savedEffects !== undefined) {
this.restoreBindings(savedEffects.modifiedBindings);
this.restoreProperties(savedEffects.modifiedProperties);
}
completion = completion.composedWith;
}
}
this.generator = saved_generator;
this.modifiedBindings = savedBindings;
Expand Down
29 changes: 29 additions & 0 deletions test/serializer/pure-functions/FatalErrorAfterJoins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if (!global.__evaluatePureFunction) global.__evaluatePureFunction = f => f();

const result = global.__evaluatePureFunction(() => {
let x, y, z;

function f() {
const getNumber = global.__abstract ? global.__abstract("function", "(() => 1)") : () => 1;
const b1 = global.__abstract ? global.__abstract("boolean", "true") : true;
const b2 = global.__abstract ? global.__abstract("boolean", "!false") : true;
const b3 = global.__abstract ? global.__abstract("boolean", "!!true") : true;

x = getNumber();
if (!b1) throw new Error("abrupt");
y = getNumber();
if (!b2) throw new Error("abrupt");
z = getNumber();
if (!b3) throw new Error("abrupt");

if (global.__fatal) global.__fatal();

return x + y + z;
}

f();

return x + y + z;
});

global.inspect = () => result;