Mercurial > urweb
comparison src/elaborate.sml @ 1985:5195378deeca
Merge in upstream
author | Patrick Hurst <phurst@mit.edu> |
---|---|
date | Sat, 15 Feb 2014 01:04:31 -0500 |
parents | 2c075e875a47 |
children | 210fb3dfc483 |
comparison
equal
deleted
inserted
replaced
1984:819756825c8d | 1985:5195378deeca |
---|---|
4479 | L'.SgnFun (m, n, dom, ran) => | 4479 | L'.SgnFun (m, n, dom, ran) => |
4480 (subSgn env loc sgn2 dom; | 4480 (subSgn env loc sgn2 dom; |
4481 case #1 (hnormSgn env ran) of | 4481 case #1 (hnormSgn env ran) of |
4482 L'.SgnError => (strerror, sgnerror, []) | 4482 L'.SgnError => (strerror, sgnerror, []) |
4483 | L'.SgnConst sgis => | 4483 | L'.SgnConst sgis => |
4484 ((L'.StrApp (str1', str2'), loc), | 4484 let |
4485 (L'.SgnConst ((L'.SgiStr (m, n, selfifyAt env {str = str2', sgn = sgn2}), loc) :: sgis), loc), | 4485 (* This code handles a tricky case that led to a very nasty bug. |
4486 gs1 @ gs2) | 4486 * An invariant about signatures of elaborated modules is that no |
4487 * identifier that could appear directly in a program is defined | |
4488 * twice. We add "?" in front of identifiers where necessary to | |
4489 * maintain the invariant, but the code below, to extend a functor | |
4490 * body with a binding for the functor argument, wasn't written | |
4491 * with the invariant in mind. Luckily for us, references to | |
4492 * an identifier later within a signature work by globally | |
4493 * unique index, so we just need to change the string name in the | |
4494 * new declaration. *) | |
4495 val m = | |
4496 if List.exists (fn (L'.SgiStr (x, _, _), _) => x = m | |
4497 | _ => false) sgis then | |
4498 "?" ^ m | |
4499 else | |
4500 m | |
4501 in | |
4502 ((L'.StrApp (str1', str2'), loc), | |
4503 (L'.SgnConst ((L'.SgiStr (m, n, selfifyAt env {str = str2', sgn = sgn2}), loc) :: sgis), loc), | |
4504 gs1 @ gs2) | |
4505 end | |
4487 | _ => raise Fail "Unable to hnormSgn in functor application") | 4506 | _ => raise Fail "Unable to hnormSgn in functor application") |
4488 | _ => (strError env (NotFunctor sgn1); | 4507 | _ => (strError env (NotFunctor sgn1); |
4489 (strerror, sgnerror, [])) | 4508 (strerror, sgnerror, [])) |
4490 end | 4509 end |
4491 | 4510 |