Permalink
Browse files

fixed mangling of lambda names (regressed as of ae88177)

fixes #165
  • Loading branch information...
1 parent e0926ab commit 6217aaba5f5f6004005d2b03d52ead6fc2cf9e9e @mishoo committed Jul 1, 2011
Showing with 13 additions and 7 deletions.
  1. +13 −7 lib/process.js
View
@@ -482,21 +482,27 @@ function ast_mangle(ast, options) {
};
function _lambda(name, args, body) {
- var is_defun = this[0] == "defun";
- if (is_defun && name) name = get_mangled(name);
- body = with_scope(body.scope, function(){
- if (!is_defun && name) {
- name = scope.set_mangle(name, scope.parent.next_mangled());
+ var is_defun = this[0] == "defun", extra;
+ if (name) {
+ if (is_defun) name = get_mangled(name);
+ else {
+ extra = {};
+ name = extra[name] = scope.next_mangled();
}
+ }
+ body = with_scope(body.scope, function(){
args = MAP(args, function(name){ return get_mangled(name) });
return MAP(body, walk);
- });
+ }, extra);
return [ this[0], name, args, body ];
};
- function with_scope(s, cont) {
+ function with_scope(s, cont, extra) {
var _scope = scope;
scope = s;
+ if (extra) for (var i in extra) if (HOP(extra, i)) {
+ s.set_mangle(i, extra[i]);
+ }
for (var i in s.names) if (HOP(s.names, i)) {
get_mangled(i, true);
}

0 comments on commit 6217aab

Please sign in to comment.