aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lapi.js3
-rw-r--r--src/lobject.js3
2 files changed, 5 insertions, 1 deletions
diff --git a/src/lapi.js b/src/lapi.js
index 97cb061..89297cc 100644
--- a/src/lapi.js
+++ b/src/lapi.js
@@ -280,7 +280,8 @@ const lua_pushcclosure = function(L, fn, n) {
L.top -= n;
while (n--) {
- cl.upvalue[n] = L.stack[L.top + n];
+ cl.upvalue[n].setfrom(L.stack[L.top + n])
+ L.stack[L.top + n] = void 0;
}
L.stack[L.top] = new TValue(CT.LUA_TCCL, cl);
diff --git a/src/lobject.js b/src/lobject.js
index ab50af8..e4ef380 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -197,6 +197,9 @@ class CClosure {
this.f = f;
this.nupvalues = n;
this.upvalue = new Array(n); /* list of upvalues as TValues */
+ while (n--) {
+ this.upvalue[n] = new TValue(CT.LUA_TNIL, null);
+ }
}
}