From 084566b579f5f8141e0d9c55067216ded2f40cbf Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 3 Nov 2018 22:18:58 +0000 Subject: [PATCH] Complain when constructing a Structure with an undefined field, not when manipulating such a structure later --- packages/core/src/struct.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/src/struct.js b/packages/core/src/struct.js index 37f5447..de3b51f 100644 --- a/packages/core/src/struct.js +++ b/packages/core/src/struct.js @@ -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); + } } }