[vala] Improve error message on duplicate definition



commit 8d62a1e81f114861b0dc51b9c0cbfa94c95070c7
Author: Jürg Billeter <j bitron ch>
Date:   Mon Mar 22 21:21:13 2010 +0100

    Improve error message on duplicate definition
    
    Display location of previous definition.
    
    Fixes bug 591977.

 vala/valareport.vala |   26 +++++++++++++++++++++++++-
 vala/valascope.vala  |    1 +
 2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/vala/valareport.vala b/vala/valareport.vala
index 22d689d..14e3583 100644
--- a/vala/valareport.vala
+++ b/vala/valareport.vala
@@ -1,6 +1,6 @@
 /* valareport.vala
  *
- * Copyright (C) 2006-2008  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
@@ -93,6 +93,27 @@ public class Vala.Report : Object {
 	}
 
 	/**
+	 * Reports the specified message as note.
+	 *
+	 * @param source  reference to source code
+	 * @param message note message
+	 */
+	public virtual void note (SourceReference? source, string message) {
+		if (!enable_warnings) {
+			return;
+		}
+
+		if (source == null) {
+			stderr.printf ("note: %s\n", message);
+		} else {
+			stderr.printf ("%s: note: %s\n", source.to_string (), message);
+			if (verbose_errors) {
+				report_source (source);
+			}
+		}
+	}
+
+	/**
 	 * Reports the specified message as warning.
 	 *
 	 * @param source  reference to source code
@@ -133,6 +154,9 @@ public class Vala.Report : Object {
 	}
 
 	/* Convenience methods calling warn and err on correct instance */
+	public static void notice (SourceReference? source, string message) {
+		CodeContext.get ().report.note (source, message);
+	}
 	public static void warning (SourceReference? source, string message) {
 		CodeContext.get ().report.warn (source, message);
 	}
diff --git a/vala/valascope.vala b/vala/valascope.vala
index afab10a..a2a946b 100644
--- a/vala/valascope.vala
+++ b/vala/valascope.vala
@@ -66,6 +66,7 @@ public class Vala.Scope {
 				} else {
 					Report.error (sym.source_reference, "`%s' already contains a definition for `%s'".printf (owner.get_full_name (), name));
 				}
+				Report.notice (lookup (name).source_reference, "previous definition of `%s' was here".printf (name));
 				return;
 			}
 



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