diff options
-rw-r--r-- | stdlib/hashtbl.ml | 1 | ||||
-rw-r--r-- | stdlib/hashtbl.mli | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/stdlib/hashtbl.ml b/stdlib/hashtbl.ml index ba5995b3e..fd8574d93 100644 --- a/stdlib/hashtbl.ml +++ b/stdlib/hashtbl.ml @@ -29,6 +29,7 @@ and ('a, 'b) bucketlist = | Cons of 'a * 'b * ('a, 'b) bucketlist let create initial_size = + if initial_size <= 0 then invalid_arg "hashtbl__new" else { max_len = 3; data = Array.create initial_size Empty } let clear h = diff --git a/stdlib/hashtbl.mli b/stdlib/hashtbl.mli index c3bf841ca..10096c9fa 100644 --- a/stdlib/hashtbl.mli +++ b/stdlib/hashtbl.mli @@ -24,7 +24,8 @@ val create : int -> ('a,'b) t (* [Hashtbl.create n] creates a new, empty hash table, with initial size [n]. The table grows as needed, so [n] is just an initial guess. Better results are said to be - achieved when [n] is a prime number. *) + achieved when [n] is a prime number. + Raise [Invalid_argument "hashtbl__new"] if [n] is less than 1. *) val clear : ('a, 'b) t -> unit (* Empty a hash table. *) |