[vala] Detect shadowed variable for foreach statement without iterator



commit ae126bd66d4f2d56f0d6ca05469ede8460407b13
Author: Jürg Billeter <j bitron ch>
Date:   Sun Dec 19 16:51:34 2010 +0100

    Detect shadowed variable for foreach statement without iterator

 vala/valaforeachstatement.vala |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index 77d4f56..2ce466d 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -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 ()) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]