js-slang
js-slang copied to clipboard
Missing run-time check for correct number of arguments for display() and error()
The following call should be an error according to the spec, but is currently not an error:
display(1,"T",3);
(Note that display() is caught.)
It is a problem (and perhaps confusing for students) because:
- It does not follow the spec
- Source-defined functions and other stdlib functions are checked as per #346, so not checking display() and error() is even more surprising
could you help to review pr #732? it would be easy to do a length check of the arguments with the newer implementation. thanks!
Yes, error() and display() give runtime error, but passing more than two arguments leads to silently ignoring the extra arguments. Should be an easy fix.
Perhaps beyond just a runtime check, we also want to support type-checking for typed variants (see #1398).