Description
Expected Behavior
Blocks in Scratch 2 and 3 behave the same except for intentional differences
Actual Behavior
The switch to costume block interprets "Infinity" as a number in 3.0, and switches to the first costume. In 2.0 it is always considered a string, and the costume does not switch unless there is a costume named "Infinity"
There are probably other blocks that are affected in a similar way. The root is https://github.com/LLK/scratch-flash/blob/646523e6846ad0dd993213a38b46fe2ea511d026/src/primitives/Primitives.as#L151
Items are only compared as numbers if they contain digits in 2.0. Since Infinity does not, it always gets interpreted as a string, whereas in JS the Number() cast recognizes the string "Infinity" as a number.
Steps to Reproduce
See #1754 (comment) for the original comment and context (@joker314)
- Load the Scratch Cat sprite, which has two costumes
- Switch to the second costume (e.g. manually)
- Drag out a "switch to costume" block
- Place a "join Infin ity" block as the argument to the "switch costume" block
- Click on the block
In Scratch 2.0, Infinity is not considered a number (since it contains no digits), and is therefore considered a non-existent costume--remaining at costume 2. However, the current Scratch 3.0 implementation parses this as a number, which causes it to go to the first costume (1).
Operating System and Browser
all