# HG changeset patch
# User Mario de Sousa <msousa@fe.up.pt>
# Date 1306515661 -3600
# Node ID d120740a6b588d01a6e7b82db9191306f05d95e0
# Parent  de1be61482fae13f62bc5557d0992535b1c0d495
Fixing bug related to setting array variables with values coming from other variables
(e.g. X[0] := Y;)

diff -r de1be61482fa -r d120740a6b58 stage4/generate_c/generate_c_st.cc
--- a/stage4/generate_c/generate_c_st.cc	Tue May 17 10:35:12 2011 +0100
+++ b/stage4/generate_c/generate_c_st.cc	Fri May 27 18:01:01 2011 +0100
@@ -155,6 +155,7 @@
 		symbol_c* value,
 		symbol_c* fb_symbol = NULL,
 		symbol_c* fb_value = NULL) {
+  
   unsigned int vartype = search_varfb_instance_type->get_vartype(symbol);
   if (vartype == search_var_instance_decl_c::external_vt) {
     symbolic_variable_c *variable = dynamic_cast<symbolic_variable_c *>(symbol);
@@ -185,10 +186,17 @@
   }
   else
     wanted_variablegeneration = complextype_base_vg;
+  
   symbol->accept(*this);
   s4o.print(",");
   wanted_variablegeneration = expression_vg;
   print_check_function(type, value, fb_value);
+  /* We need to call search_varfb_instance_type->get_vartype() again, as it may have been called
+   * again since we called it in the beginning of this print_setter() function.
+   * This make sure the call to search_varfb_instance_type->type_is_complex() will return
+   * the correct value regarding our 'symbol'.
+   */
+  search_varfb_instance_type->get_vartype(symbol);
   if (search_varfb_instance_type->type_is_complex()) {
     s4o.print(",");
     wanted_variablegeneration = complextype_suffix_vg;