From 0fe7eca0185dd8907c49f0657a2f0f613ede106b Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Wed, 13 Dec 2017 15:37:58 -0500 Subject: [PATCH] Fix procedure name lookup to work with undefined procedures. --- src/blocks/scratch3_procedures.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/blocks/scratch3_procedures.js b/src/blocks/scratch3_procedures.js index 3ba743d8b..7fb31d28f 100644 --- a/src/blocks/scratch3_procedures.js +++ b/src/blocks/scratch3_procedures.js @@ -27,15 +27,17 @@ class Scratch3ProcedureBlocks { call (args, util) { if (!util.stackFrame.executed) { const procedureCode = args.mutation.proccode; - const [paramNames, paramIds] = util.getProcedureParamNamesAndIds(procedureCode); + const paramNamesAndIds = util.getProcedureParamNamesAndIds(procedureCode); // If null, procedure could not be found, which can happen if custom // block is dragged between sprites without the definition. // Match Scratch 2.0 behavior and noop. - if (paramNames === null) { + if (paramNamesAndIds === null) { return; } + const [paramNames, paramIds] = paramNamesAndIds; + for (let i = 0; i < paramIds.length; i++) { if (args.hasOwnProperty(paramIds[i])) { util.pushParam(paramNames[i], args[paramIds[i]]);