js-slang icon indicating copy to clipboard operation
js-slang copied to clipboard

Missing run-time check for correct number of arguments for display() and error()

Open btzy opened this issue 4 years ago • 3 comments

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

btzy avatar Aug 12 '20 13:08 btzy

could you help to review pr #732? it would be easy to do a length check of the arguments with the newer implementation. thanks!

dtlay avatar Aug 14 '20 01:08 dtlay

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.

martin-henz avatar Mar 30 '24 09:03 martin-henz

Perhaps beyond just a runtime check, we also want to support type-checking for typed variants (see #1398).

RichDom2185 avatar Mar 31 '24 04:03 RichDom2185