summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Delamarre <cedric.delamarre@scilab-enterprises.com>2016-10-25 17:44:38 +0200
committerAntoine ELIAS <antoine.elias@scilab-enterprises.com>2016-11-04 14:13:57 +0100
commit77184480060485b0eb646fd8ecda40a6d7d847cd (patch)
treefc8f1e8a0c1723b35f499c4b6b7d8187afd75777
parente535a8f96674bce4297a8e74d4dde37eacf780fd (diff)
downloadscilab-77184480060485b0eb646fd8ecda40a6d7d847cd.zip
scilab-77184480060485b0eb646fd8ecda40a6d7d847cd.tar.gz
[bug_14437] struct clone missing when ref is more than 1
test_run ast bug_14437 Change-Id: I165e1113cb8153f415761a44df4c472c8c2f881c
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/ast/src/cpp/ast/visitor_common.cpp9
-rw-r--r--scilab/modules/ast/tests/nonreg_tests/bug_14437.dia.ref19
-rw-r--r--scilab/modules/ast/tests/nonreg_tests/bug_14437.tst22
4 files changed, 51 insertions, 0 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 745bd9c..1c97be3 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -346,6 +346,7 @@ Bug Fixes
346* [#14379](http://bugzilla.scilab.org/show_bug.cgi?id=14379): Problem with lists of functions having 2 arguments. 346* [#14379](http://bugzilla.scilab.org/show_bug.cgi?id=14379): Problem with lists of functions having 2 arguments.
347* [#14395](http://bugzilla.scilab.org/show_bug.cgi?id=14395): `dir` displayed a []+".." warning when no subdirectory exists. 347* [#14395](http://bugzilla.scilab.org/show_bug.cgi?id=14395): `dir` displayed a []+".." warning when no subdirectory exists.
348* [#14411](http://bugzilla.scilab.org/show_bug.cgi?id=14411): abort crashes scilab in a loop while 348* [#14411](http://bugzilla.scilab.org/show_bug.cgi?id=14411): abort crashes scilab in a loop while
349* [#14437](http://bugzilla.scilab.org/show_bug.cgi?id=14437): Problem with the affectation cmde "=" applied to a "list of struct"
349* [#14448](http://bugzilla.scilab.org/show_bug.cgi?id=14448): removed havewindow() was still documented 350* [#14448](http://bugzilla.scilab.org/show_bug.cgi?id=14448): removed havewindow() was still documented
350* [#14461](http://bugzilla.scilab.org/show_bug.cgi?id=14461): Calling `grand(n, "markov", P, x0)` did not return all outputs. 351* [#14461](http://bugzilla.scilab.org/show_bug.cgi?id=14461): Calling `grand(n, "markov", P, x0)` did not return all outputs.
351* [#14513](http://bugzilla.scilab.org/show_bug.cgi?id=14513): `isqual` comparing two built-in functions yielded an error. 352* [#14513](http://bugzilla.scilab.org/show_bug.cgi?id=14513): `isqual` comparing two built-in functions yielded an error.
diff --git a/scilab/modules/ast/src/cpp/ast/visitor_common.cpp b/scilab/modules/ast/src/cpp/ast/visitor_common.cpp
index 76de2d4..5f3886b 100644
--- a/scilab/modules/ast/src/cpp/ast/visitor_common.cpp
+++ b/scilab/modules/ast/src/cpp/ast/visitor_common.cpp
@@ -896,6 +896,15 @@ types::InternalType* evaluateFields(const ast::Exp* _pExp, std::list<ExpHistory*
896 if (pITCurrent->isStruct()) 896 if (pITCurrent->isStruct())
897 { 897 {
898 types::Struct* pStruct = pITCurrent->getAs<types::Struct>(); 898 types::Struct* pStruct = pITCurrent->getAs<types::Struct>();
899 // In case where pStruct is in several scilab variable,
900 // we have to clone it for keep the other variables unchanged.
901 if (pStruct->getRef() > 1)
902 {
903 pStruct = pStruct->clone();
904 pEH->setCurrent(pStruct);
905 pEH->setReinsertion();
906 }
907
899 std::wstring pwcsFieldname = (*iterFields)->getExpAsString(); 908 std::wstring pwcsFieldname = (*iterFields)->getExpAsString();
900 909
901 if (pEH->needResize()) 910 if (pEH->needResize())
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14437.dia.ref b/scilab/modules/ast/tests/nonreg_tests/bug_14437.dia.ref
new file mode 100644
index 0000000..4e20c9e
--- /dev/null
+++ b/scilab/modules/ast/tests/nonreg_tests/bug_14437.dia.ref
@@ -0,0 +1,19 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Cedric Delamarre
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- Non-regression test for bug 14437 -->
8//
9// <-- Bugzilla URL -->
10// http://bugzilla.scilab.org/show_bug.cgi?id=14437
11//
12// <-- Short Description -->
13// Problem with the affectation cmde "=" applied to a "list of struct"
14lst=list();
15lst(1)=struct("f",[1,2]);
16lst(2)=lst(1);
17lst(2).f(2)=3;
18assert_checkequal(lst(1).f, [1,2]);
19assert_checkequal(lst(2).f, [1,3]);
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14437.tst b/scilab/modules/ast/tests/nonreg_tests/bug_14437.tst
new file mode 100644
index 0000000..1b126e3
--- /dev/null
+++ b/scilab/modules/ast/tests/nonreg_tests/bug_14437.tst
@@ -0,0 +1,22 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Cedric Delamarre
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- Non-regression test for bug 14437 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/show_bug.cgi?id=14437
12//
13// <-- Short Description -->
14// Problem with the affectation cmde "=" applied to a "list of struct"
15
16lst=list();
17lst(1)=struct("f",[1,2]);
18lst(2)=lst(1);
19lst(2).f(2)=3;
20
21assert_checkequal(lst(1).f, [1,2]);
22assert_checkequal(lst(2).f, [1,3]);