clearglobal() deletes local aliases only at the clearglobal statement level => Scilab CRASH
Reported by Samuel GOUGEON (@sgougeon)
BUG DESCRIPTION:
----------------
When a global variable is erased with clearglobal(), we could expect that its local instances are cleared as well.
The documentation tells that it is not the case:
----------
"NOTE : Note that clearglobal() only clears the global variables,
the local copies of these global variables are not destroyed."
----------
But either the behavior of clearglobal() could be changed to clear local instances as well,
OR the documentation MUST specify that clearglobal() MUST be used AFTER clear.
The NOTE above is specious. clearing globally a variable without first clearing its local instance(s)
yields MANY unsolvable issues:
-->clear a1; clearglobal a1
-->global a1
-->whos -name a1
Name Type Size Bytes
a1 constant 0 by 0 16
a1 constant* 0 by 0 16
-->a1 = "Test"
a1 =
Test
-->clearglobal a1
-->isdef a1 l
!--error 228
reference to the cleared global variable a1.
-->whos -name a1
Name Type Size Bytes
!--error 228
reference to the cleared global variable a1.
at line 98 of function whos called by :
whos -name a1
-->clear a1
-->whos -name a1
Name Type Size Bytes
!--error 228 <<<< IT IS BLOCKING: clear DOES NOT WORK PROPERLY
reference to the cleared global variable a1.
at line 98 of function whos called by :
whos -name a1
-->isdef a1 l
!--error 228
reference to the cleared global variable a1.
ERROR LOG:
----------
See hereabove
HOW TO REPRODUCE THE BUG:
-------------------------
clear a1; clearglobal a1
global a1
whos -name a1
a1 = "Test"
clearglobal a1
isdef a1 l
whos -name a1
clear a1
whos -name a1
isdef a1 l
OTHER INFORMATION:
------------------
Scilab 6.0.0 manages much better the situation, exactly as we could expect:
--> global a1
--> whos -name a1
Nom Type Dimensions Octets
a1 constant 0 par 0 0
a1 constant* 0 par 0 0
--> a1 = "Test"
a1 =
Test
--> clearglobal a1
--> isdef a1 l
ans =
F <<<<< PERFECT !
--> whos -name a1
Nom Type Dimensions Octets
<<<<< PERFECT !
==>
* CHANGES to be updated
* Documentation to be updated