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

Source Typed: Support multiple function signatures of builtins

Open thomastanck opened this issue 4 years ago • 2 comments

Right now builtins such as display cannot be typechecked as it has multiple signatures

  • display(v: T): T
  • display(v: T, s: string): T

Should be a small fix though.

thomastanck avatar Aug 01 '20 04:08 thomastanck

Source Typed gives: display(1, 2); Line 1: TypeError: display expects the second argument to be a string

The typechecker passes: display(); // runtime error and display(1, "asdf", 3); // no error: 3 is ignored

Is this "good enough"? should we close this issue?

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

I think we should add a runtime error if display and error have more than two arguments. There is already a runtime error for 0 arguments.

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