# HG changeset patch # User Adam Chlipala # Date 1336142302 14400 # Node ID 1e940643a5f01757139c85e1352290f03498f119 # Parent fca4a6d05ac1098149380319e4caf78e3951f32f Report which files lead to duplicate module names diff -r fca4a6d05ac1 -r 1e940643a5f0 src/compiler.sml --- a/src/compiler.sml Fri May 04 10:33:04 2012 -0400 +++ b/src/compiler.sml Fri May 04 10:38:22 2012 -0400 @@ -894,10 +894,13 @@ 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 @@ 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,