]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Detect shadowed variable for foreach statement without iterator
authorJürg Billeter <j@bitron.ch>
Sun, 19 Dec 2010 15:51:34 +0000 (16:51 +0100)
committerJürg Billeter <j@bitron.ch>
Sun, 19 Dec 2010 15:51:34 +0000 (16:51 +0100)
vala/valaforeachstatement.vala

index 77d4f5603cda8cf5c9ff18a45816b0488f182bdf..2ce466d9557f2e8aa8333c89fe485e44e5b5ef6c 100644 (file)
@@ -350,7 +350,7 @@ public class Vala.ForeachStatement : Block {
                        return false;
                }
 
-               element_variable = new LocalVariable (type_reference, variable_name);
+               element_variable = new LocalVariable (type_reference, variable_name, null, source_reference);
 
                body.scope.add (variable_name, element_variable);
 
@@ -362,6 +362,10 @@ public class Vala.ForeachStatement : Block {
                owner = context.analyzer.current_symbol.scope;
                context.analyzer.current_symbol = this;
 
+               // call add_local_variable to check for shadowed variable
+               add_local_variable (element_variable);
+               remove_local_variable (element_variable);
+
                body.check (context);
 
                foreach (LocalVariable local in get_local_variables ()) {