From: Jürg Billeter Date: Sat, 20 Mar 2010 10:01:20 +0000 (+0100) Subject: Warn on assignment to same variable X-Git-Tag: 0.8.0~161 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=71f035af6a4ec1b119757ecd75874db32dc3acf8;p=thirdparty%2Fvala.git Warn on assignment to same variable --- diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala index 877d3ed35..38fda74de 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;