@@ -1301,6 +1301,93 @@ suite('Procedures', function () {
13011301 } ,
13021302 ) ;
13031303
1304+ test (
1305+ 'when a procedure definition block is deleted, deleting its callers ' +
1306+ 'with arguments that call another procedure does not cause a crash' ,
1307+ function ( ) {
1308+ // This test exercises the scenario reported in
1309+ // https://github.com/google/blockly-samples/issues/2557
1310+ Blockly . serialization . workspaces . load (
1311+ {
1312+ blocks : {
1313+ languageVersion : 0 ,
1314+ blocks : [
1315+ {
1316+ type : 'procedures_defnoreturn' ,
1317+ id : 'dosomething' ,
1318+ extraState : {
1319+ procedureId : 'dosomething_procmodel' ,
1320+ } ,
1321+ fields : {
1322+ NAME : 'do something' ,
1323+ } ,
1324+ } ,
1325+ {
1326+ type : 'procedures_defreturn' ,
1327+ id : 'dosomething2' ,
1328+ extraState : {
1329+ procedureId : 'dosomething2_procmodel' ,
1330+ } ,
1331+ fields : {
1332+ NAME : 'do something2' ,
1333+ } ,
1334+ } ,
1335+ {
1336+ type : 'procedures_callnoreturn' ,
1337+ id : 'call_dosomething' ,
1338+ extraState : {
1339+ name : 'do something' ,
1340+ params : [ 'x' ] ,
1341+ } ,
1342+ inputs : {
1343+ ARG0 : {
1344+ block : {
1345+ type : 'procedures_callreturn' ,
1346+ id : 'call_dosomething2' ,
1347+ extraState : {
1348+ name : 'do something2' ,
1349+ } ,
1350+ } ,
1351+ } ,
1352+ } ,
1353+ } ,
1354+ ] ,
1355+ } ,
1356+ variables : [
1357+ {
1358+ name : 'x' ,
1359+ id : 'x_var' ,
1360+ } ,
1361+ ] ,
1362+ procedures : [
1363+ {
1364+ id : 'dosomething_procmodel' ,
1365+ name : 'do something' ,
1366+ returnTypes : null ,
1367+ parameters : [
1368+ {
1369+ id : 'x_param' ,
1370+ name : 'x' ,
1371+ } ,
1372+ ] ,
1373+ } ,
1374+ {
1375+ id : 'dosomething2_procmodel' ,
1376+ name : 'do something2' ,
1377+ returnTypes : [ ] ,
1378+ } ,
1379+ ] ,
1380+ } ,
1381+ this . workspace ,
1382+ ) ;
1383+
1384+ const defBlock = this . workspace . getBlockById ( 'dosomething' ) ;
1385+ // Should not cause an exception to be thrown.
1386+ defBlock . dispose ( ) ;
1387+ globalThis . clock . runAll ( ) ;
1388+ } ,
1389+ ) ;
1390+
13041391 test (
13051392 'when a procedure definition block is deleted, a delete event for ' +
13061393 'its data model is fired' ,
0 commit comments