Complain when constructing a Structure with an undefined field, not when manipulating such a structure later

This commit is contained in:
Tony Garnock-Jones 2018-11-03 22:18:58 +00:00
parent 8e7cf160d6
commit 084566b579
1 changed files with 3 additions and 0 deletions

View File

@ -73,6 +73,9 @@ function Structure(meta, fields) {
this.fields = fields.slice(0);
for (var i = 0; i < fields.length; i++) {
this[i] = fields[i] = Immutable.fromJS(fields[i]);
if (this[i] === void 0) {
throw new Error("Structure: cannot contain undefined value at field " + i);
}
}
}