changeset 569:86fa0d36da51

Reporting location of symbol conflict error more accurately.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 29 Dec 2007 21:57:33 +0100
parents c8861b452eb3
children 3ebdc510a7fc
files trunk/src/dil/Location.d trunk/src/dil/Scope.d
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/Location.d	Sat Dec 29 21:10:34 2007 +0100
+++ b/trunk/src/dil/Location.d	Sat Dec 29 21:57:33 2007 +0100
@@ -85,4 +85,5 @@
     }
     return col;
   }
+  alias calculateColumn colNum;
 }
--- a/trunk/src/dil/Scope.d	Sat Dec 29 21:10:34 2007 +0100
+++ b/trunk/src/dil/Scope.d	Sat Dec 29 21:57:33 2007 +0100
@@ -43,7 +43,11 @@
   {
     auto sym = symbol.lookup(var.ident);
     if (sym)
-      error("variable '"~var.ident.str~"' conflicts with another definition in its scope");
+    {
+      auto loc = sym.node.begin.getLocation();
+      auto locString = Format("{}({},{})", loc.filePath, loc.lineNum, loc.colNum);
+      error(var.node.begin, "variable '"~var.ident.str~"' conflicts with symbol @"~locString);
+    }
     else
       symbol.insert(var, var.ident);
   }
@@ -102,9 +106,9 @@
     infoMan ~= new SemanticError(location, GetMsg(mid));
   }
 
-  void error(char[] msg)
+  void error(Token* token, char[] msg)
   {
-    auto location = new Location("", 0);
+    auto location = token.getLocation();
     infoMan ~= new SemanticError(location, msg);
   }
 }