changeset 2173:010ce27228f1

Proper error message for excessively fancy FFI signatures
author Adam Chlipala <adam@chlipala.net>
date Thu, 27 Aug 2015 16:28:45 -0400
parents 3b4a5604ed97
children ce312cad5ecd c05851bf7861
files src/elaborate.sml tests/empty.ur tests/ffisub.urp tests/ffisub.urs
diffstat 3 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/elaborate.sml	Thu Aug 20 15:11:40 2015 -0400
+++ b/src/elaborate.sml	Thu Aug 27 16:28:45 2015 -0400
@@ -4123,6 +4123,18 @@
 
                          val dNew = (L'.DFfiStr (x, n, sgn'), loc)
                      in
+                         case #1 sgn' of
+                             L'.SgnConst sgis =>
+                             (case List.find (fn (L'.SgiConAbs _, _) => false
+                                             | (L'.SgiCon _, _) => false
+                                             | (L'.SgiDatatype _, _) => false
+                                             | (L'.SgiVal _, _) => false
+                                             | _ => true) sgis of
+                                  NONE => ()
+                                | SOME sgi => (ErrorMsg.errorAt loc "Disallowed signature item for FFI module";
+                                               epreface ("item", p_sgn_item env sgi)))
+                           | _ => raise Fail "FFI signature isn't SgnConst";
+
                          Option.map (fn tm => ModDb.insert (dNew, tm)) tmo;
                          ([dNew], (env', denv, enD gs' @ gs))
                      end)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ffisub.urp	Thu Aug 27 16:28:45 2015 -0400
@@ -0,0 +1,3 @@
+ffi ffisub
+
+empty
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ffisub.urs	Thu Aug 27 16:28:45 2015 -0400
@@ -0,0 +1,5 @@
+structure S : sig
+  type t
+end
+
+val x : S.t