summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2012-05-04 10:38:22 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2012-05-04 10:38:22 -0400
commitd216e49c1b5e7f25d95e9cb1dd8bcdbbc71389c5 (patch)
tree97e2d53eeb5ce11f87f879edb7ab95ecbf1b05e6
parent802fc606ff18c261eb591d7ae6dbb99fe9c48af9 (diff)
Report which files lead to duplicate module names
-rw-r--r--src/compiler.sml26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/compiler.sml b/src/compiler.sml
index c92cd832..dbc478f0 100644
--- a/src/compiler.sml
+++ b/src/compiler.sml
@@ -894,10 +894,13 @@ structure SM = BinaryMapFn(struct
val moduleRoots = ref ([] : (string * string) list)
fun addModuleRoot (k, v) = moduleRoots := (k, v) :: !moduleRoots
-structure SS = BinarySetFn(struct
- type ord_key = string
- val compare = String.compare
- end)
+structure SK = struct
+type ord_key = string
+val compare = String.compare
+end
+
+structure SS = BinarySetFn(SK)
+structure SM = BinaryMapFn(SK)
val parse = {
func = fn {database, sources = fnames, ffi, onError, ...} : job =>
@@ -1099,12 +1102,15 @@ val parse = {
ignore (List.foldl (fn (d, used) =>
case #1 d of
Source.DStr (x, _, _, _) =>
- if SS.member (used, x) then
- (ErrorMsg.errorAt (#2 d) ("Duplicate top-level module name " ^ x);
- used)
- else
- SS.add (used, x)
- | _ => used) SS.empty ds);
+ (case SM.find (used, x) of
+ SOME loc =>
+ (ErrorMsg.error ("Duplicate top-level module name " ^ x);
+ Print.prefaces "Files" [("Previous", Print.PD.string (ErrorMsg.spanToString loc)),
+ ("Current", Print.PD.string (ErrorMsg.spanToString (#2 d)))];
+ used)
+ | NONE =>
+ SM.insert (used, x, #2 d))
+ | _ => used) SM.empty ds);
ds
end handle Empty => ds
end,