source-academy/js-slang

Behavior of math functions when used with incorrectly typed arguments

Closed this issue · 1 comments

In JavaScript

math_sin(false); // returns 0

converting false to 0. Our (untyped) Source variants follow this behavior. This is currently not documented. Should we keep this behavior or should we restrict the argument types?

In JavaScript

math_sin(false); // returns 0

converting false to 0. Our (untyped) Source variants follow this behavior. This is currently not documented. Should we keep this behavior or should we restrict the argument types?

I think we can say that the behavior is not defined when the arguments are not numbers – I feel we should keep it consistent with how Math.XXX does things (in terms of behavior), but open to comments if you think otherwise