-
Notifications
You must be signed in to change notification settings - Fork 16
Description
I haven't tested but it seems that a procedure input which gets passed onto random might, for example, lose the decimal suffix in 123.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 from string (when non-strings are desired).