Commit ba4281cb authored by Sergio Costas's avatar Sergio Costas

Now can detect when a variable is being initialized incorrectly

parent 222fbbe4
......@@ -209,9 +209,8 @@ class crusty(object):
variable = self._find_variable(var_container, var_name, line_number)
if (not force) and ((variable["properties"] & self.PROPERTY_CRUST_VARIABLE) != 0):
status = variable["status"]
if (status == crusty.STATUS_NOT_NULL) or (status == crusty.STATUS_NULL) or (status == crusty.STATUS_NOT_NULL_OR_NULL):
if (status == crusty.STATUS_NOT_NULL) or (status == crusty.STATUS_NOT_NULL_OR_NULL):
self._add_error(self.MSG_WARNING,_("Initializing {:s} at line {:d}, which was already initialized at line {:d}").format(var_name,line_number,variable["init_line"]))
return
variable["init_line"] = line_number
variable["status"] = value
......@@ -405,11 +404,24 @@ class crusty(object):
options = self._eval_assignment(node.assignment,var_container,function_container)
if len(options) > 1:
for option in options[1:]:
# create a new "execution thread" for each possible assignment value
newvar_container = self._copy_container(var_container)
self._set_var_value(newvar_container,node.name,option,node.line)
self._process_block(tree[counter+1:],newvar_container,function_container)
self._set_var_value(var_container,node.name,options[0],node.line)
continue
if node.type == "=":
varname = node.child1[0].name
var_defined = self._find_variable(var_container,varname,node.line)
options = self._eval_assignment(node.child2,var_container,function_container)
if len(options) > 1:
for option in options[1:]:
# create a new "execution thread" for each possible assignment value
newvar_container = self._copy_container(var_container)
self._set_var_value(newvar_container,varname,option,node.line)
self._process_block(tree[counter+1:],newvar_container,function_container)
self._set_var_value(var_container,varname,options[0],node.line)
continue
# if node.type == "FOR":
# print("Tipo: {:s}; Nombre: {:s}".format(str(node.type),str(node.name)))
# b1,b2 = lib.get_next_block(tree[counter+1:])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment