[Scilab-users] Scilab 6 - Problem with scope and nested lists

Arvid Rosén arvid at softube.com
Fri Oct 16 14:55:33 CEST 2020


Hi,

The minimal case I posted mimics the situation where the problem was found. Removing the struct, and using just to levels of lists, does not trigger the same problem. I have played around with this a bit, and yet haven’t found a smaller case to trigger the issue.

Cheers,
Arvid


From: Scilab Users List <users-bounces at lists.scilab.org> on behalf of Stéphane Mottelet <stephane.mottelet at utc.fr>
Reply to: Users mailing list for Scilab <users at lists.scilab.org>
Date: Friday, 16 October 2020 at 14:20
To: "users at lists.scilab.org" <users at lists.scilab.org>
Subject: Re: [Scilab-users] Scilab 6 - Problem with scope and nested lists


Your test mix struct and lists can you reproduce it without using a struct ?
Le 16/10/2020 à 14:15, Arvid Rosén a écrit :
Hi,

I already filed a report here:
 https://bugzilla.scilab.org/show_bug.cgi?id=16556<https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/show_bug.cgi?id=16556>

Do you want a more compact example than that?

Here is an even more slimmed version.


Cheers,
Arvid

----------

// Define variables
testArray = list(list([]));
testArray(1)(1).testMember = 1;
testArrayOrig = testArray;

// Define function
function outArray = testFunc(inArray)
    inArray(1)(1).testMember = 5
    outArray = inArray;
endfunction

// Send the variable as argument to the function
testArrayOut = testFunc(testArray);

if testArrayOut(1)(1).testMember == testArray(1)(1).testMember
    error("Error! inputArgument was changed by function");
end


--

From: Scilab Users List <users-bounces at lists.scilab.org><mailto:users-bounces at lists.scilab.org> on behalf of Stéphane Mottelet <stephane.mottelet at utc.fr><mailto:stephane.mottelet at utc.fr>
Reply to: Users mailing list for Scilab <users at lists.scilab.org><mailto:users at lists.scilab.org>
Date: Friday, 16 October 2020 at 13:40
To: "users at lists.scilab.org"<mailto:users at lists.scilab.org> <users at lists.scilab.org><mailto:users at lists.scilab.org>
Subject: Re: [Scilab-users] Scilab 6 - Problem with scope and nested lists


Hello,

I think that this is a sufficiently serious issue to diserve a report in bugzilla.scilab.org. But could you prepare a more compact example ?

S.
Le 16/10/2020 à 13:35, Arvid Rosén a écrit :
Hi!

We have found a tricky issue when moving over from Scilab 5 to Scilab 6 in my organization. We have a lot of code which works with nested lists, and functions modifying those lists. However, when a function is called with some nested lists as an input argument, the body of that function can change the value of the variable in the calling scope. This was not the case in Scilab 5, and the issue is super tricky to hunt down in our quite extensive code base. Below is a short example of the problem, and how to reproduce it.

I have also filed a bug report here: https://bugzilla.scilab.org/show_bug.cgi?id=16556<https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/bugzilla.scilab.org/show_bug.cgi?id=16556>

Is anyone else seeing this problem? And do you have any workarounds or other suggestions?

Cheers,
Arvid

------

// Define variables
testArray = list();
for i=1:1:10
    testArray($+1) = list();
    for j=1:1:10
        testArray(i)($+1) = [];
        testArray(i)(j).testMember = 1;
    end
end
testArrayOrig = testArray;

// Define functions
function outArray = testFunc(inArray)
    for i=1:1:10
        for j=1:1:10
            inArray(i)(j).testMember = 5
        end
    end
    outArray = inArray;
endfunction

// Send the variable as argument to the function
if %t
    testArrayOut = testFunc2(testArray);

    if testArrayOut(1)(1).testMember == testArray(1)(1).testMember
        error("Error! inputArgument was changed by function");
    end
end




_______________________________________________

users mailing list

users at lists.scilab.org<mailto:users at lists.scilab.org>

https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users<https://antispam.utc.fr/proxy/2/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users>

--

Stéphane Mottelet

Ingénieur de recherche

EA 4297 Transformations Intégrées de la Matière Renouvelable

Département Génie des Procédés Industriels

Sorbonne Universités - Université de Technologie de Compiègne

CS 60319, 60203 Compiègne cedex

Tel : +33(0)344234688

http://www.utc.fr/~mottelet<https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/www.utc.fr/~mottelet>
-->



_______________________________________________

users mailing list

users at lists.scilab.org<mailto:users at lists.scilab.org>

https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users

--

Stéphane Mottelet

Ingénieur de recherche

EA 4297 Transformations Intégrées de la Matière Renouvelable

Département Génie des Procédés Industriels

Sorbonne Universités - Université de Technologie de Compiègne

CS 60319, 60203 Compiègne cedex

Tel : +33(0)344234688

http://www.utc.fr/~mottelet
-->
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20201016/6a00ac7d/attachment.htm>


More information about the users mailing list