FES: Add detection for trailing undefined arguments #4606
Merged
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 #4571
Changes:
Consider the following few examples
Here g and b are undefined. But earlier as color with only one argument was still a valid overload, the FES did not log a message. But as it is passed 3 arguments, it is likely that them being undefined is unintentional and so a message should be displayed.
Now it shows:
🌸 p5.js says: color() was expecting Number for parameter #1 (zero-based index), received an empty variable instead
🌸 p5.js says: color() was expecting Number for parameter #2 (zero-based index), received an empty variable instead
Similarly:
would not have logged an error before this, as the undefined argument is trailing and select(string) is a valid overload. A message here is important to let the user know that
a
is empty ( i.enotexistant
was not found )Now it shows:
🌸 p5.js says: select() was expecting String|p5.Element|HTMLElement for parameter #1 (zero-based index), received an empty variable instead.
Also for
Earlier we used to get
🌸 p5.js says: circle() was expecting at least 3 arguments, but received only 2
Now it correctly shows:
🌸 p5.js says: circle() was expecting Number for parameter #2 (zero-based index), received an empty variable instead.
PR Checklist
npm run lint
passes