fix: block creation successful with undefined messages (#7591)

closes #7589

Signed-off-by: Oscar <71343264+0scvr@users.noreply.github.com>
This commit is contained in:
Oscar
2023-10-17 20:19:17 +02:00
committed by GitHub
parent ec4e6a2d30
commit 3a03f4d11b

View File

@@ -1641,6 +1641,18 @@ export class Block implements IASTNodeLocation, IDeletable {
);
}
// Validate that each arg has a corresponding message
let n = 0;
while (json['args' + n]) {
if (json['message' + n] === undefined) {
throw Error(
warningPrefix +
`args${n} must have a corresponding message (message${n}).`,
);
}
n++;
}
// Set basic properties of block.
// Makes styles backward compatible with old way of defining hat style.
if (json['style'] && json['style'].hat) {