map: Produce 0 instead of NaN for non-numeric string values
This has been a problem for...ever, but the old classification system (and calculations) had `||0` for ever variable reference, whereas the new one does not; NaNs result in undefined behavior in the new classification system, since those values are not expected to exist. This ought to have automated tests, but it will be rewritten in TAMER. DEV-10484main
parent
fb5f38d14c
commit
501a9441a5
11
RELEASES.md
11
RELEASES.md
|
@ -14,6 +14,17 @@ commits that introduce the changes. To make a new release, run
|
|||
`tools/mkrelease`, which will handle updating the heading for you.
|
||||
|
||||
|
||||
NEXT
|
||||
====
|
||||
This is a bugfix release.
|
||||
|
||||
Compiler
|
||||
--------
|
||||
- Input maps will now ensure that non-numeric string values result in `0`
|
||||
rather than `NaN`, the latter of which results in undefined behavior in
|
||||
the new classification system.
|
||||
|
||||
|
||||
v19.0.0 (2022-03-01)
|
||||
====================
|
||||
This version includes a backwards-incomplatible change to enable the new
|
||||
|
|
|
@ -2414,7 +2414,7 @@
|
|||
{
|
||||
// TODO: error
|
||||
if ( Array.isArray( input ) ) input = input[0];
|
||||
return ( input === '' || input === undefined ) ? value : +input;
|
||||
return ( input === '' || input === undefined ) ? value : +input||0;
|
||||
}
|
||||
|
||||
// TODO: error for both
|
||||
|
@ -2428,9 +2428,9 @@
|
|||
return input.map( function( x ) {
|
||||
return ( depth === 2 )
|
||||
? Array.isArray( x )
|
||||
? x.map( function(s) { return +s; } )
|
||||
? x.map( function(s) { return +s||0; } )
|
||||
: [ x ]
|
||||
: ( x === '' || x === undefined ) ? value : +x;
|
||||
: ( x === '' || x === undefined ) ? value : +x||0;
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -796,7 +796,7 @@
|
|||
<call-template name="lvmc:gen-input-default">
|
||||
<with-param name="sym" select="$sym" />
|
||||
<with-param name="from-str">
|
||||
<text>''+val[i]</text>
|
||||
<text>+val[i]||0</text>
|
||||
</with-param>
|
||||
<!-- We have to reduce the nesting level by one because of
|
||||
our outer loop, but we do not want to go below 0, which
|
||||
|
|
Loading…
Reference in New Issue