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 <[email protected]> on behalf of Stéphane Mottelet <[email protected]>
*Reply to: *Users mailing list for Scilab <[email protected]>
*Date: *Friday, 16 October 2020 at 13:40
*To: *"[email protected]" <[email protected]>
*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

    [email protected]  <mailto:[email protected]>

    
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
[email protected]
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

_______________________________________________
users mailing list
[email protected]
http://lists.scilab.org/mailman/listinfo/users

Reply via email to