diff options
-rw-r--r-- | src/elaborate.sml | 34 | ||||
-rw-r--r-- | tests/strdupe.lac | 11 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/elaborate.sml b/src/elaborate.sml index 6cd587d9..64613703 100644 --- a/src/elaborate.sml +++ b/src/elaborate.sml @@ -1578,6 +1578,40 @@ and elabStr env (str, loc) = let val (ds', env') = ListUtil.foldlMapConcat elabDecl env ds val sgis = map sgiOfDecl ds' + + val (sgis, _, _, _, _) = + foldr (fn (sgall as (sgi, loc), (sgis, cons, vals, sgns, strs)) => + case sgi of + L'.SgiConAbs (x, _, _) => + (if SS.member (cons, x) then + sgnError env (DuplicateCon (loc, x)) + else + (); + (sgall :: sgis, SS.add (cons, x), vals, sgns, strs)) + | L'.SgiCon (x, _, _, _) => + (if SS.member (cons, x) then + sgnError env (DuplicateCon (loc, x)) + else + (); + (sgall :: sgis, SS.add (cons, x), vals, sgns, strs)) + | L'.SgiVal (x, _, _) => + if SS.member (vals, x) then + (sgis, cons, vals, sgns, strs) + else + (sgall :: sgis, cons, SS.add (vals, x), sgns, strs) + | L'.SgiSgn (x, _, _) => + (if SS.member (sgns, x) then + sgnError env (DuplicateSgn (loc, x)) + else + (); + (sgall :: sgis, cons, vals, SS.add (sgns, x), strs)) + | L'.SgiStr (x, _, _) => + (if SS.member (strs, x) then + sgnError env (DuplicateStr (loc, x)) + else + (); + (sgall :: sgis, cons, vals, sgns, SS.add (strs, x)))) + ([], SS.empty, SS.empty, SS.empty, SS.empty) sgis in ((L'.StrConst ds', loc), (L'.SgnConst sgis, loc)) end diff --git a/tests/strdupe.lac b/tests/strdupe.lac new file mode 100644 index 00000000..834a48af --- /dev/null +++ b/tests/strdupe.lac @@ -0,0 +1,11 @@ +val x = 0 +val x = 1 + +type t = int +(*type t = int*) + +signature S = sig end +(*signature S = sig end*) + +structure S = struct end +(*structure S = struct end*) |