Skip to content

Handle NaN / undefined values

Marco Trevisan requested to merge 3v1n0/gjs:handle-nan-values into master

As per the arg refactor we may end up using JS::ToNumber to convert undefined values, unfortunately this has the side effect of causing the returned value to be set to NaN and leading to issue #379 (closed).

To keep the behavior with JS/C expectations, let's handle an undefined value consistently as 0 when converting to an Integer type, while keep considering it a NaN when converting to a floating point value (as it'd happen when using Number(undefined)).

Added tests.

Merge request reports