aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tag.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 17:25:51 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2011-12-03 17:25:51 -0500
commit87e2e610a69b268d10a22a7142a44a2c0afd4799 (patch)
tree946b720078be0609810fff15dd02bd9966310209 /src/tag.sml
parent40098da68420bb08aa0aa0889fa5298fd005c245 (diff)
Don't crash on invalid URL head terms during Tag
Diffstat (limited to 'src/tag.sml')
-rw-r--r--src/tag.sml61
1 files changed, 33 insertions, 28 deletions
diff --git a/src/tag.sml b/src/tag.sml
index a313e0a6..dc648739 100644
--- a/src/tag.sml
+++ b/src/tag.sml
@@ -65,38 +65,43 @@ fun exp env (e, s) =
| _ => (ErrorMsg.errorAt loc ("Invalid " ^ newAttr
^ " expression");
Print.epreface ("Expression",
- CorePrint.p_exp CoreEnv.empty eOrig);
+ CorePrint.p_exp env eOrig);
(0, []))
val (f, args) = unravel e
-
- val (cn, count, tags, newTags) =
- case IM.find (tags, f) of
- NONE =>
- (count, count + 1, IM.insert (tags, f, count),
- (ek, f, count) :: newTags)
- | SOME cn => (cn, count, tags, newTags)
-
- val (_, _, _, s) = E.lookupENamed env f
-
- val byTag = case SM.find (byTag, s) of
- NONE => SM.insert (byTag, s, (ek, f))
- | SOME (ek', f') =>
- (if f = f' then
- ()
- else
- ErrorMsg.errorAt loc
- ("Duplicate HTTP tag "
- ^ s);
- if ek = ek' then
- ()
- else
- both (loc, s);
- byTag)
-
- val e = (EClosure (cn, args), loc)
in
- (e, (count, tags, byTag, newTags))
+ if f = 0 then
+ (e, (count, tags, byTag, newTags))
+ else
+ let
+ val (cn, count, tags, newTags) =
+ case IM.find (tags, f) of
+ NONE =>
+ (count, count + 1, IM.insert (tags, f, count),
+ (ek, f, count) :: newTags)
+ | SOME cn => (cn, count, tags, newTags)
+
+ val (_, _, _, s) = E.lookupENamed env f
+
+ val byTag = case SM.find (byTag, s) of
+ NONE => SM.insert (byTag, s, (ek, f))
+ | SOME (ek', f') =>
+ (if f = f' then
+ ()
+ else
+ ErrorMsg.errorAt loc
+ ("Duplicate HTTP tag "
+ ^ s);
+ if ek = ek' then
+ ()
+ else
+ both (loc, s);
+ byTag)
+
+ val e = (EClosure (cn, args), loc)
+ in
+ (e, (count, tags, byTag, newTags))
+ end
end
in
case e of