diff compiler.js @ 55:93ddb4ad6fcb

Fix some nested closure bugs
author Mike Pavone <pavone@retrodev.com>
date Fri, 13 Jul 2012 21:05:52 -0700
parents 976a0924e1d4
children 08ae75d90dc2
line wrap: on
line diff
--- a/compiler.js	Fri Jul 13 19:22:39 2012 -0700
+++ b/compiler.js	Fri Jul 13 21:05:52 2012 -0700
@@ -152,6 +152,7 @@
 		} else {
 			if (nestedcall) {
 				this.closedover[name] = true;
+				this.passthruenv = false;
 			} 
 			if (name in this.closedover) {
 				var ret = {
@@ -171,12 +172,16 @@
 		if (ret) {
 			if (ret.type == 'closedover') {
 				ret.type = 'upvar';
-				ret.depth = 1;
-			} else if (ret.type == 'upvar') {
-				if (Object(this.closedover).keys.length) {
+				ret.depth = 0;
+			}
+			if (ret.type == 'upvar') {
+				if (Object.keys(this.closedover).length) {
 					ret.depth++;
 				} else {
 					this.passthruenv = true;
+					if (ret.depth == 0) {
+						ret.depth = 1;
+					}
 				}
 			}
 		}