From 45c36f898202ab850d973d0f4147e15b6782d358 Mon Sep 17 00:00:00 2001 From: Tobias Weinert Date: Wed, 27 Apr 2022 17:00:47 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20JSON=20deserialization=20fails=20(bug=20?= =?UTF-8?q?#6091)=20(collapsed=20procedure=20call=E2=80=A6=20(#6103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: JSON deserialization fails (bug #6091) (collapsed procedure call blocks) * fix: JSON deserialization fails (bug #6091) changed fix, added tests (collapsed procedure call blocks) --- blocks/procedures.js | 9 ++++---- tests/mocha/serializer_test.js | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/blocks/procedures.js b/blocks/procedures.js index 8e652ed3906..21afdb7fa38 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -721,10 +721,10 @@ const PROCEDURE_CALL_COMMON = { if (!mutatorOpen) { this.quarkConnections_ = {}; this.quarkIds_ = null; - } - if (!paramIds) { - // Reset the quarks (a mutator is about to open). - return; + } else { + // fix #6091 - this call could cause an error when outside if-else + // expanding block while mutating prevents another error (ancient fix) + this.setCollapsed(false); } // Test arguments (arrays of strings) for changes. '\n' is not a valid // argument name character, so it is a valid delimiter here. @@ -736,7 +736,6 @@ const PROCEDURE_CALL_COMMON = { if (paramIds.length !== paramNames.length) { throw RangeError('paramNames and paramIds must be the same length.'); } - this.setCollapsed(false); if (!this.quarkIds_) { // Initialize tracking for this block. this.quarkConnections_ = {}; diff --git a/tests/mocha/serializer_test.js b/tests/mocha/serializer_test.js index 85247cc98d9..9ddb4a90e32 100644 --- a/tests/mocha/serializer_test.js +++ b/tests/mocha/serializer_test.js @@ -1674,12 +1674,52 @@ Serializer.Mutations.Procedure.Caller = new SerializerTestCase( '' + '' + ''); +Serializer.Mutations.Procedure.CollapsedProceduresCallreturn = new SerializerTestCase( + 'CollapsedProceduresCallreturn', + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + 'do something' + + 'Describe this function...' + + '' + + '' + + '' + + '' + + '' + + '' + + ''); +Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn = new SerializerTestCase( + 'CollapsedProceduresCallnoreturn', + '' + + '' + + 'x' + + '' + + '' + + '' + + '' + + '' + + 'do something' + + 'Describe this function...' + + '' + + '' + + '' + + '' + + '' + + '' + + ''); Serializer.Mutations.Procedure.testCases = [ Serializer.Mutations.Procedure.NoMutation, Serializer.Mutations.Procedure.Variables, Serializer.Mutations.Procedure.NoStatements, Serializer.Mutations.Procedure.IfReturn, Serializer.Mutations.Procedure.Caller, + Serializer.Mutations.Procedure.CollapsedProceduresCallreturn, + Serializer.Mutations.Procedure.CollapsedProceduresCallnoreturn, ]; Serializer.Mutations.Procedure.Names = new SerializerTestSuite('Names');