Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made a significant adjustment to the behavior of custom reporters for the local Scratch instance I use in classrooms. I don't know if this is desirable in TurboWarp, but I wanted to offer the change back upstream.
I did my best to maintain code quality, but I'm not a professional developer, so I apologize if some cleanup is needed.
Resolves
Not Applicable.
Proposed Changes
If every return block connected to a block definition returns a boolean (as in, the
_
in everyreturn _
is a hexagon block), the call block will itself become hexagon-shaped, and able to be dropped in boolean inputs.Block definitions with mixed return types will be ovals. Non-boolean "oval" call blocks cannot be dropped into boolean inputs.
Reason for Changes
In TurboWarp's current
return
experiment, it is impossible to create boolean hexagonal reporters. As a workaround, TurboWarp allows non-boolean custom reporters to be dropped into boolean inputs, but this runs somewhat counter to how Scratch's type system is supposed to work†. I rely on the shape system when I teach elementary school students.Implementation Notes
In order to make this work, I set
Blockly.Procedures.blockContainsReturn
to run on every block connection/disconnection. I don't love this, but it was the best I could get working on my own. The function is already debounced, and I don't think it's doing anything resource intensive?However, this has one notable side effect. If you:
return
from the block definition. (For usability reasons, the instance of the call block you already attached will not change shape.)...the call block will snap to its updated shape the moment it is detached. As it happens, I greatly prefer this behavior anyway.
Test Coverage
Tested manually. (And not super extensively, but I'm relatively confident nothing will break.)
† Vanilla Scratch does allow
item _ of list
anditem # of _ in list
to be dropped into boolean inputs, but I think this is also kind of bad. It runs counter to the behavior of every other block.