-
Notifications
You must be signed in to change notification settings - Fork 32
Closed
Description
Consider the following program:
import { draw_connected, make_point } from 'curve';
draw_connected((t, _) => make_point(0.5, t));draw_connected expects a callback that only takes 1 parameter, so when the curve is evaluated the function is called with a single parameter.
js-slang checks that every function is called with an expected number of parameters, so at the point of curve evaluation an error is thrown because the callback gets called with only 1 parameter:
As seen above, the error isn't very informative.
In accordance with the principle that modules should keep their implementation details hidden, it might be necessary for bundle functions to implement checks to ensure that callback functions have the correct number of parameters:
function isValidCallback(f: unknown): f is (arg0: unknown, arg1: unknown) => unknown {
return typeof f === 'function' && f.length === 2;
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels