|
@@ -1725,7 +1725,7 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|
FuncState *fs = ls->fs;
|
|
FuncState *fs = ls->fs;
|
|
BCLine line = ls->linenumber;
|
|
BCLine line = ls->linenumber;
|
|
GCtab *t = NULL;
|
|
GCtab *t = NULL;
|
|
- int vcall = 0, needarr = 0, fixt = 0;
|
|
|
|
|
|
+ int vcall = 0, needarr = 0;
|
|
uint32_t narr = 1; /* First array index. */
|
|
uint32_t narr = 1; /* First array index. */
|
|
uint32_t nhash = 0; /* Number of hash entries. */
|
|
uint32_t nhash = 0; /* Number of hash entries. */
|
|
BCReg freg = fs->freereg;
|
|
BCReg freg = fs->freereg;
|
|
@@ -1769,9 +1769,10 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|
lj_gc_anybarriert(fs->L, t);
|
|
lj_gc_anybarriert(fs->L, t);
|
|
if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */
|
|
if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */
|
|
expr_kvalue(fs, v, &val);
|
|
expr_kvalue(fs, v, &val);
|
|
- } else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */
|
|
|
|
- settabV(fs->L, v, t); /* Preserve key with table itself as value. */
|
|
|
|
- fixt = 1; /* Fix this later, after all resizes. */
|
|
|
|
|
|
+ /* Mark nil value with table value itself to preserve the key. */
|
|
|
|
+ if (key.k == VKSTR && tvisnil(v)) settabV(fs->L, v, t);
|
|
|
|
+ } else { /* Preserve the key for the following non-const store. */
|
|
|
|
+ settabV(fs->L, v, t);
|
|
goto nonconst;
|
|
goto nonconst;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -1813,17 +1814,6 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|
} else {
|
|
} else {
|
|
if (needarr && t->asize < narr)
|
|
if (needarr && t->asize < narr)
|
|
lj_tab_reasize(fs->L, t, narr-1);
|
|
lj_tab_reasize(fs->L, t, narr-1);
|
|
- if (fixt) { /* Fix value for dummy keys in template table. */
|
|
|
|
- Node *node = noderef(t->node);
|
|
|
|
- uint32_t i, hmask = t->hmask;
|
|
|
|
- for (i = 0; i <= hmask; i++) {
|
|
|
|
- Node *n = &node[i];
|
|
|
|
- if (tvistab(&n->val)) {
|
|
|
|
- lj_assertFS(tabV(&n->val) == t, "bad dummy key in template table");
|
|
|
|
- setnilV(&n->val); /* Turn value into nil. */
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
lj_gc_check(fs->L);
|
|
lj_gc_check(fs->L);
|
|
}
|
|
}
|
|
}
|
|
}
|