aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Chlipala <adam@chlipala.net>2018-05-20 19:28:17 -0400
committerAdam Chlipala <adam@chlipala.net>2018-05-20 19:28:17 -0400
commit3e8fc5122fed2baee3a4d27d51575f6dd5174ea8 (patch)
tree64a5e2411cc1a2d2d3b31ca62c5ca605daa5dd74
parent077666b77bf21054e1e1f67ba61dfbaf57525378 (diff)
Proper error message when the body of a 'val' declaration fails to check against the type annotation
-rw-r--r--src/elaborate.sml3
-rw-r--r--tests/pairUnify.ur6
2 files changed, 8 insertions, 1 deletions
diff --git a/src/elaborate.sml b/src/elaborate.sml
index 4a04d4bf..51d00bd8 100644
--- a/src/elaborate.sml
+++ b/src/elaborate.sml
@@ -4046,7 +4046,8 @@ and elabDecl (dAll as (d, loc), (env, denv, gs)) =
| L.PAnnot (p', _) => singleVar p'
| _ => NONE
in
- unifyCons env loc et pt;
+ (unifyCons env loc et pt
+ handle CUnify (c1, c2, env', err) => expError env (Unify (e', c1, c2, env', err)));
(case exhaustive (env, et, [p'], loc) of
NONE => ()
diff --git a/tests/pairUnify.ur b/tests/pairUnify.ur
new file mode 100644
index 00000000..1c9f9759
--- /dev/null
+++ b/tests/pairUnify.ur
@@ -0,0 +1,6 @@
+datatype a = A
+datatype b = B
+
+val x : a * b = (A, B)
+
+val y : b = x