Skip to content

Commit 9ca434d

Browse files
committed
Blocks: Set function with return call block type
The function call block now checks what the return type of the function definition block is, in order to determine its own type. Also, fixes issue where some blocks had block inputs attached but no connections (caused by mutations editing the available inputs).
1 parent 599da1e commit 9ca434d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

blockly/blocks/procedures.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,14 @@ Blockly.Blocks['procedures_callreturn'] = {
772772
mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom,
773773
domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation,
774774
renameVar: Blockly.Blocks['procedures_callnoreturn'].renameVar,
775-
customContextMenu: Blockly.Blocks['procedures_callnoreturn'].customContextMenu
775+
customContextMenu:
776+
Blockly.Blocks['procedures_callnoreturn'].customContextMenu,
777+
/** @return {!string} Return value type from the function definition block. */
778+
getBlockType: function() {
779+
var defBlock = Blockly.Procedures.getDefinition(this.getProcedureCall(),
780+
this.workspace);
781+
return defBlock.getReturnType();
782+
}
776783
};
777784

778785
Blockly.Blocks['procedures_ifreturn'] = {

blockly/core/types.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ Blockly.Types.getChildBlockType = function(block) {
166166
// Only checks first input block, so it decides the type. Incoherences amongst
167167
// multiple inputs dealt at a per-block level with their own block warnings
168168
while (nextBlock && (nextBlock.getBlockType === undefined) &&
169-
(nextBlock.inputList.length > 0)) {
169+
(nextBlock.inputList.length > 0) &&
170+
(nextBlock.inputList[0].connection)) {
170171
nextBlock = nextBlock.inputList[0].connection.targetBlock();
171172
}
172173
if (nextBlock === block) {

0 commit comments

Comments
 (0)