Skip to content

fix: replace toString with String in switch blocks#472

Open
OceanIsEndless wants to merge 1 commit intoscratchfoundation:developfrom
OceanIsEndless:patch-1
Open

fix: replace toString with String in switch blocks#472
OceanIsEndless wants to merge 1 commit intoscratchfoundation:developfrom
OceanIsEndless:patch-1

Conversation

@OceanIsEndless
Copy link

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 undefined as 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.

@OceanIsEndless OceanIsEndless requested a review from a team as a code owner March 13, 2026 17:44
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@OceanIsEndless

This comment was marked as resolved.

@OceanIsEndless OceanIsEndless changed the title prevent weird behavior when switching costume fix: prevent switching costume blocks from hanging Mar 13, 2026
@OceanIsEndless OceanIsEndless changed the title fix: prevent switching costume blocks from hanging fix: replace toString with String in switch blocks Mar 13, 2026
Prevent switch costume to (), switch backdrop to (), switch backdrop to () and wait from hanging
@OceanIsEndless

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant