]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Improve error message on duplicate definition
authorJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 20:21:13 +0000 (21:21 +0100)
committerJürg Billeter <j@bitron.ch>
Mon, 22 Mar 2010 20:21:13 +0000 (21:21 +0100)
Display location of previous definition.

Fixes bug 591977.

vala/valareport.vala
vala/valascope.vala

index 22d689d41aa632e153ef51249d7b1c37e71c140c..14e358376cb3a4877553b06e88e091eef1574ec3 100644 (file)
@@ -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);
        }
index afab10aa4c6904f05d935f2d48e202e0d8279902..a2a946b09968a513166283e9739627c1fb5557a6 100644 (file)
@@ -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;
                        }