rescript-core icon indicating copy to clipboard operation
rescript-core copied to clipboard

Workaround for Math variadic functions

Open aspeddro opened this issue 2 years ago • 3 comments

This ensures that the return for an empty array does not return -Infinity

TODO:

  • [x] Update CHANGELOG

See https://github.com/rescript-association/rescript-core/issues/53

aspeddro avatar Mar 02 '23 00:03 aspeddro

Might it be better to just remove the @variadic?

If you remove @variadic the compiler passes an array. Math.min([1, 2]) returns NaN

Playground

aspeddro avatar Jul 26 '23 13:07 aspeddro

If you remove @variadic the compiler passes an array. Math.min([1, 2]) returns NaN

Ah, sorry, I didn't mean to include that. I checked after writing it, but apparently forgot to remove the comment. Please see the other comments instead :)

glennsl avatar Jul 26 '23 13:07 glennsl

I was wondering and not sure if we should return 0.0. Maybe let returns Infinity.

aspeddro avatar Jul 27 '23 21:07 aspeddro