* [#16399](https://bugzilla.scilab.org/16399): `mtlb_zeros([])` was crashing Scilab.
* [#16401](https://bugzilla.scilab.org/16401): global `external_object_java` class was crashing Scilab.
* [#16403](https://bugzilla.scilab.org/16403): 1D extraction of matrix with implicit index had wrong dimensions.
+* [#16408](https://bugzilla.scilab.org/16408): toJSON(var, indent, filename) is the right call sequence. Documentation has been udpated.
### Bugs fixed in 6.1.0:
<title>Syntax</title>
<synopsis>
result = toJSON(var)
+ result = toJSON(var, indent)
result = toJSON(var, filename)
- result = toJSON(var, filename, indent)
+ result = toJSON(var, indent, filename)
</synopsis>
</refsynopsisdiv>
<refsection>
case 3:
{
//must be a scalar double or single string
- if (!scilab_isDouble(env, in[1]) && !scilab_isScalar(env, in[1]))
+ if (!scilab_isDouble(env, in[1]) || !scilab_isScalar(env, in[1]))
{
Scierror(999, "%s: Wrong type for input argument #%d: double expected.\n", name.data(), 2);
return STATUS_ERROR;
indent = (int)dbl;
//must be a scalar double or single string
- if (!scilab_isString(env, in[2]) && !isScalar(env, in[2]))
+ if (!scilab_isString(env, in[2]) || !isScalar(env, in[2]))
{
Scierror(999, "%s: Wrong type for input argument #%d: string expected.\n", name.data(), 3);
return STATUS_ERROR;
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2020 - ESI Group - Adeline CARNIS
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+
+// <-- Non-regression test for bug 16408 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=16408
+//
+// <-- Short Description -->
+// toJSON(var, filename, indent) is wrong and crashed.
+// toJSON(var, indent, filename) is the right call sequence. Documentation
+// has been udpated.
+// =============================================================================
+
+assert_checkfalse(execstr("toJSON([""a"" ""b""], tempname(), 1)" ,"errcatch") == 0);
+refMsg = msprintf(_("%s: Wrong type for input argument #%d: double expected.\n"), "toJSON", 2);
+assert_checkerror("toJSON([""a"" ""b""], tempname(), 1)", refMsg);