[vala] Warn on assignment to same variable



commit 71f035af6a4ec1b119757ecd75874db32dc3acf8
Author: Jürg Billeter <j bitron ch>
Date:   Sat Mar 20 11:01:20 2010 +0100

    Warn on assignment to same variable

 vala/valaassignment.vala |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 877d3ed..38fda74 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -1,6 +1,6 @@
 /* valaassignment.vala
  *
- * Copyright (C) 2006-2009  Jürg Billeter
+ * Copyright (C) 2006-2010  Jürg Billeter
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -356,6 +356,12 @@ public class Vala.Assignment : Expression {
 					}
 				}
 			}
+
+			var right_ma = right as MemberAccess;
+			if (right_ma != null && ma.symbol_reference == right_ma.symbol_reference &&
+			    (ma.symbol_reference is LocalVariable || ma.symbol_reference is Field || ma.symbol_reference is FormalParameter)) {
+				Report.warning (source_reference, "Assignment to same variable");
+			}
 		} else if (left is ElementAccess) {
 			var ea = (ElementAccess) left;
 



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