Cast sprite name to string before getSpriteTargetByName #2038
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.
Resolves
#1743
Proposed Changes
For blocks that use
getSpriteTargetByName
, cast the sprite name to a string before passing togetSpriteTargetByName
. These are the blocks that are fixed by this change:Reason for Changes
Currently
getSpriteTargetByName
doesn't cast sprite names to a string, so any sprites with a number for a name might not be found if a number is the type of the value passed togetSpriteTargetByName
. As discussed in #1743, it would generally be better to have this string casting done in one place instead of having the same logic repeated in multiple blocks. I am doing this non-DRY solution for now however because @mzgoddard has plans as part of his performance optimizations to make the string casting happen elsewhere in the VM in one place. That work is being tracked in #2013Test Coverage
I added sprite-number-name.sb2 as one of the tests run by execute.js.