From 8d62a1e81f114861b0dc51b9c0cbfa94c95070c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Mon, 22 Mar 2010 21:21:13 +0100 Subject: [PATCH] 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 deletion(-) diff --git a/vala/valareport.vala b/vala/valareport.vala index 22d689d41..14e358376 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 @@ -92,6 +92,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. * @@ -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 afab10aa4..a2a946b09 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; } -- 2.47.3