Bug: check for constructor overflow in [exp] fields

The check for constructor overflow was considering only fields with
explicit names, ignoring fields with syntax '[exp]=exp'.
This commit is contained in:
Roberto Ierusalimschy
2025-05-20 17:55:08 -03:00
parent d1ee2a4deb
commit 267ef461d0

View File

@@ -849,12 +849,11 @@ static void recfield (LexState *ls, ConsControl *cc) {
FuncState *fs = ls->fs;
int reg = ls->fs->freereg;
expdesc tab, key, val;
if (ls->t.token == TK_NAME) {
checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
if (ls->t.token == TK_NAME)
codename(ls, &key);
}
else /* ls->t.token == '[' */
yindex(ls, &key);
checklimit(fs, cc->nh, MAX_INT, "items in a constructor");
cc->nh++;
checknext(ls, '=');
tab = *cc->t;