espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.76k stars 741 forks source link

Missing cases in `jswCallFunctionHack` #2328

Open notEvil opened 1 year ago

notEvil commented 1 year ago

Hi,

test_typed_array_sort.js fails in Linux 32bit build with

ASSERT(jsvGetLocks(var) < 15) FAILED AT src/jsvar.c:800
  #1[r1,l2] Object { 
    #2[r1,l2] ASSERT(jsvGetLocks(var) < 15) FAILED AT src/jsvar.c:780
EXITING.

because jswCallFunctionHack in gen/jswrapper.c doesn't handle the call signatures of _jswrap_arraybufferview_sort_float and _jswrap_arraybufferview_sort_int (jspeFunctionCall in _jswrap_array_sort_compare returns null pointer from which a float is forcefully extracted). With

/*JSON{
  "type" : "",
  "generate" : "",
  "params" : [
    ["a", "float", ""],
    ["b", "float", ""]
  ],
  "return" : ["float", ""]
}*/
/*JSON{
  "type" : "",
  "generate" : "",
  "params" : [
    ["a", "int", ""],
    ["b", "int", ""]
  ],
  "return" : ["int", ""]
}*/

the test succeeds.