Fix structure field deletion by inserting null(). 27/15927/1
Vincent COUVERT [Tue, 10 Feb 2015 08:44:28 +0000 (09:44 +0100)]
To test: test_run data_structures struct

Change-Id: I0d51831893a3ea3d38960254203426c630fc4b75

scilab/modules/ast/src/cpp/ast/visitor_common.cpp

index cea9f1c..8842d6b 100644 (file)
@@ -2064,12 +2064,20 @@ InternalType* insertionCall(const ast::Exp& e, typed_list* _pArgs, InternalType*
                     throw ast::ScilabError(os.str(), 999, e.getLocation());
                 }
 
-                pStruct->addField(pS->get(0));
-                for (int i = 0; i < pStruct->getSize(); i++)
+                if (_pInsert->isListDelete())
                 {
-                    pStruct->get(i)->set(pS->get(0), _pInsert);
+                    /* Remove a field */
+                    pStruct->removeField(pS->get(0));
+                }
+                else
+                {
+                    /* Add a field */
+                    pStruct->addField(pS->get(0));
+                    for (int i = 0; i < pStruct->getSize(); i++)
+                    {
+                        pStruct->get(i)->set(pS->get(0), _pInsert);
+                    }
                 }
-
                 pRet = pStruct;
             }
             else // insert something in a struct