Commit 8d62a1e8 authored by Jürg Billeter's avatar Jürg Billeter

Improve error message on duplicate definition

Display location of previous definition.

Fixes bug 591977.
parent f91a0466
/* 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);
}
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment