-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Expected Behavior
Argument defaults clearly set in the Scratch json:
Argument defaults in procedures should be used when a nullish input is received. For string (%s) and number (%n) inputs, a blank input ("") should be detected, and the default value should be used.
This means that a procedure call, empty values, as well as arguments not existing, should trigger the use of argument defaults.
Actual Behavior
In reality, the VM uses if (Object.prototype.hasOwnProperty.call(args, paramIds[i])) {
in scratch3_procedures.js, which means that it checks for the argument's existence instead. This means that even when inputs are blank (nullish), the program just uses a blank argument.
Steps to Reproduce
Steps to reproduce the behavior:
- Go to 'https://scratch.mit.edu/projects/1193044263/'
- Click on 'See Inside'
- Click the procedure call with empty parameters
greet () () <>
and notice its lack of use of argument defaults, despite empty parameters - Click on the procedure call with parameters
greet (george) (hello) <(1)=(1)>
and notice its use of regular arguments - Click on the procedure call with parameters
example number ( )
and notice how it DOES use the argument default. This is because I have removed its input in the json, effectively making it undefined
System Details
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Screenshots