]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Warn on assignment to same variable
authorJürg Billeter <j@bitron.ch>
Sat, 20 Mar 2010 10:01:20 +0000 (11:01 +0100)
committerJürg Billeter <j@bitron.ch>
Sat, 20 Mar 2010 10:01:20 +0000 (11:01 +0100)
vala/valaassignment.vala

index 877d3ed35bf9dbf527b8a716469e2489fcdf10af..38fda74de334cc676c3aea9313b8bd5eeda93c10 100644 (file)
@@ -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;