fix: replace toString with String in switch blocks#472
Open
OceanIsEndless wants to merge 1 commit intoscratchfoundation:developfrom
Open
fix: replace toString with String in switch blocks#472OceanIsEndless wants to merge 1 commit intoscratchfoundation:developfrom
OceanIsEndless wants to merge 1 commit intoscratchfoundation:developfrom
Conversation
Contributor
|
All contributors have signed the CLA ✍️ ✅ |
This comment was marked as resolved.
This comment was marked as resolved.
Prevent switch costume to (), switch backdrop to (), switch backdrop to () and wait from hanging
This comment was marked as off-topic.
This comment was marked as off-topic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prevents the switch costume to (), switch backdrop to (), and switch backdrop to () and wait blocks from hanging indefinitely in certain situations.
Resolves
N/A (I would rather not create an issue for this, as it's not a problem that would be faced by users using Scratch as intended.)
Proposed Changes
This is a super minor change, it just prevents the switch costume to (), switch backdrop to (), and switch backdrop to () and wait blocks from hanging indefinitely in certain situations by changing them to use String() instead of .toString when converting the input to a string.
Reason for Changes
To be more consistent with other blocks.
As far as I can tell, all other blocks in the runtime do not rely on the .toString method being available on values passed as input. These blocks do, so if they're given a value without a .toString method, they will throw an error (after which the blocks are run again, and again, and again, throwing the same error and never continuing the script). Changing it to use String() makes it more consistent with other blocks. While for most intents and purposes this will never be an issue, it will prevent it from failing under extraordinary circumstances, e.g. if it is given
undefinedas input, which does not have a .toString method.Test Coverage
N/A? I'll add a test for it if it's absolutely necessary, but the behavior is effectively the same as before, it just does not throw when given an invalid value.