From 49dde317c5f211c47c84f84658d6bf96e4b98f9f Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 1 Feb 2018 16:31:36 +0000 Subject: Fix a bug where local variables could shadow functions Currently the fix is to disallow this shadowing entirely, because it seems to cause trouble for ocaml. --- src/type_check.ml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/type_check.ml b/src/type_check.ml index 2b558421..2ce7aebf 100644 --- a/src/type_check.ml +++ b/src/type_check.ml @@ -743,6 +743,9 @@ end = struct let add_local id mtyp env = begin wf_typ env (snd mtyp); + if Bindings.mem id env.top_val_specs then + typ_error (id_loc id) ("Local variable " ^ string_of_id id ^ " is already bound as a function name") + else (); typ_print ("Adding local binding " ^ string_of_id id ^ " :: " ^ string_of_mtyp mtyp); { env with locals = Bindings.add id mtyp env.locals } end -- cgit v1.2.3