fromSb3: Auto-coercing "number/text" procedure inputs into numbers loses data #112
Labels
blocked
This is blocked on other changes or resolutions
compatibility
Mismatch or currently unsupported language behavior
fmt: SB3
Pertains to SB3 format (Scratch 3.0)
I haven't tested but it seems that a procedure input which gets passed onto
random
might, for example, lose the decimal suffix in123.0
with obvious semantic value — as well as more subtle string-vs-number cases in Scratch.As complete compatibility with Scratch hadn't been a major concern, this wasn't a major issue, but now that we're narrowing in and recently did a lot of work on type-casting compatibility, we should ensure this is compatible.
It's OK to always serialize the input as a string, which is a quick fix, but we can do better with static analysis: if the argument is only ever passed to block inputs which take numbers and not any other types, it's safe to coerce the input into a number. (See #93, foundational to this kind of analysis.)
This is possibly a separate issue, but we may want to reinspect how the type of procedure arguments is interpreted: if a procedure input is only ever provided with number-returning blocks (or coerced numbers), we can treat the return type of the argument block as
number
, but otherwise we have to convert it fromstring
(when non-strings are desired).The text was updated successfully, but these errors were encountered: