BUG DESCRIPTION:
----------------
~true
true(2,3)
// are correctly converted into
~%T
ones(2,3)==1
// but
~true(2,3) % is incorrectly converted into
~ones(2,3)==1 // instead of
~(ones(2,3)==1)
Indeed, up to Scilab 5.5.2, =='s precedence was bigger than ~'s one.
But that's no longer the case with Scilab 6 ; and (~ones(2,3))==1 is incorrect.
--> code = ["true''" "true(2,3)''" "~true" "~true(2,3)"]'
code =
"true'"
"true(2,3)'"
"~true"
"~true(2,3)"
--> mputl(code, mfile+".m");
--> mfile2sci(mfile+".m", TMPDIR)
.../...
--> converted = mgetl(mfile+".sci")
converted =
""
"%t'"
"(ones(2,3)==1)'"
"~%t"
"~ones(2,3)==1"
ERROR LOG:
----------
None. Wrong translation.
HOW TO REPRODUCE THE BUG:
-------------------------
mfile = TMPDIR+"/bug_16571";
code = ["true''" "true(2,3)''" "~true" "~true(2,3)"]'
mputl(code, mfile+".m");
mfile2sci(mfile+".m", TMPDIR)
converted = mgetl(mfile+".sci")
OTHER INFORMATION:
------------------
* The transposition -- that is another unary operator -- is well converted: It puts () when it is required (see the above example).
* After fixing this bug, some unit tests will have to be updated. Noticeably for the IS* functions.
Currently (or at least after https://codereview.scilab.org/21610),
ispc % is converted into
getos()=="Windows" // while ..
~ispc % is badly converted into
~getos()=="Windows" // that yields an error
--> ~getos()
Undefined operation for the given operands.
check or define function %c_5 for overloading.
instead of
~(getos()=="Windows")