Don't allow zero-length patterns to be loaded from a file
authorRichard W.M. Jones <rich@annexia.org>
Fri, 4 Jul 2008 12:35:06 +0000 (12:35 +0000)
committerRichard W.M. Jones <rich@annexia.org>
Fri, 4 Jul 2008 12:35:06 +0000 (12:35 +0000)
pa_bitmatch.ml

index ef4d8eb..98151a3 100644 (file)
@@ -791,7 +791,10 @@ let load_patterns_from_file _loc filename =
   let names = List.rev !names in
   List.iter (
     function
-    | name, P.Pattern patt -> add_named_pattern _loc name patt
+    | name, P.Pattern patt ->
+       if patt = [] then
+         locfail _loc (sprintf "pattern %s: no fields" name);
+       add_named_pattern _loc name patt
     | _, P.Constructor _ -> () (* just ignore these for now *)
   ) names