opt out of tail recursion optimisation if the owner id has been reassigned - fixes #744

This commit is contained in:
Sebastian McKenzie
2015-02-11 11:27:50 +11:00
parent 56a953df64
commit db93c52182
4 changed files with 46 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
// we need to deopt `test` if it's reassigned as we can't be certain of it's
// state, ie. it could have been rebound or dereferenced
function test(exit) {
if (exit) {
return this.x;
}
return test(true);
}
test = test.bind({ x: "yay" });
console.log(test());

View File

@@ -0,0 +1,15 @@
"use strict";
// we need to deopt `test` if it's reassigned as we can't be certain of it's
// state, ie. it could have been rebound or dereferenced
function test(exit) {
if (exit) {
return this.x;
}
return test(true);
}
test = test.bind({ x: "yay" });
console.log(test());