-
Notifications
You must be signed in to change notification settings - Fork 2k
arguments.callee
breaks inside generated closures
#792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Woah, I didn't realise Coffeescript compiled that way. The most appropriate solution would be to pass it through as an argument, using |
@Tesco: Nice, and much cleaner! I'm amazed that having |
Darn. Reverted, reopening. |
|
FYI: satyr/coco#4 |
This may come as a shock to absolutely no-one, but the value of
arguments.callee
changes inside generated closures:test = ->
callees = arguments.callee for i from 0 to 0
callees[0]
One possible solution is to cache the value of
arguments
in the outer function, and then reinstate it in the closure, rather than passing it withapply()
:var test;
test = function() {
var _result, callees, i, self;
var _arguments = arguments;
callees = (function() {
arguments = _arguments;
_result = [];
for (i = 0; i <= 0; i++) {
_result.push(arguments.callee);
}
return _result;
}).apply(this);
return callees[0];
};
test() === test; // true!
I don't know if
arguments
is made mutable by the spec, but this hack works in v8.The text was updated successfully, but these errors were encountered: