diff options
author | Marius Kintel <marius@kintel.net> | 2012-12-01 03:18:44 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2013-03-11 21:54:49 (GMT) |
commit | 40d9ffe6a4c26eef22a6804329c736e081447a0a (patch) | |
tree | c3db921c93d0e5f26f35522ce09ede3773e7ffae /src/parser.y | |
parent | adb16cb7ddb4cfae5d6eb4027778f92d282b4493 (diff) |
Changed redeclaration of assignment so that the last declaration defines the order. This hopefully fixes the confusing error message discussed on the mailing list nov 27-30 (Variable bug)
Diffstat (limited to 'src/parser.y')
-rw-r--r-- | src/parser.y | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/parser.y b/src/parser.y index 3e485ff..536f4ef 100644 --- a/src/parser.y +++ b/src/parser.y @@ -151,19 +151,10 @@ statement: } } | TOK_ID '=' expr ';' { - bool add_new_assignment = true; - for (size_t i = 0; i < currmodule->assignments_var.size(); i++) { - if (currmodule->assignments_var[i] != $1) - continue; - delete currmodule->assignments_expr[i]; - currmodule->assignments_expr[i] = $3; - add_new_assignment = false; - } - if (add_new_assignment) { - currmodule->assignments_var.push_back($1); - currmodule->assignments_expr.push_back($3); - free($1); - } + std::list<std::string>::iterator found = std::find(currmodule->assignments_var.begin(), currmodule->assignments_var.end(),$1); + if (found != currmodule->assignments_var.end()) currmodule->assignments_var.erase(found); + currmodule->assignments_var.push_back($1); + currmodule->assignments[$1] = $3; } | TOK_MODULE TOK_ID '(' arguments_decl optional_commas ')' { Module *p = currmodule; |