spec.functionName transformer: hasBinding(name) returns true for built-in globals, so we attempt to rename the binding but it doesn't exist so exits early, add a check that doesn't perform the renaming and instead uses the wrapper - fixes #1598

This commit is contained in:
Sebastian McKenzie 2015-05-21 18:43:55 +01:00
parent 52a2e3e17c
commit 7dbde208ef
3 changed files with 23 additions and 1 deletions

View File

@ -20,7 +20,7 @@ var visitor = {
var wrap = function (state, method, id, scope) { var wrap = function (state, method, id, scope) {
if (state.selfReference) { if (state.selfReference) {
if (scope.hasBinding(id.name)) { if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) {
// we can just munge the local binding // we can just munge the local binding
scope.rename(id.name); scope.rename(id.name);
} else { } else {

View File

@ -0,0 +1,5 @@
var test = {
setInterval: function(fn, ms) {
setInterval(fn, ms);
}
};

View File

@ -0,0 +1,17 @@
"use strict";
var test = {
setInterval: (function (_setInterval) {
function setInterval(_x, _x2) {
return _setInterval.apply(this, arguments);
}
setInterval.toString = function () {
return _setInterval.toString();
};
return setInterval;
})(function (fn, ms) {
setInterval(fn, ms);
})
};