summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-02-01 16:31:36 +0000
committerAlasdair Armstrong2018-02-01 16:31:36 +0000
commit49dde317c5f211c47c84f84658d6bf96e4b98f9f (patch)
tree4e3fac053bc551fcdddcaf53579a30adb36a2c20 /src
parente9311f6ba7a59db19417902403880753530cb788 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/type_check.ml3
1 files changed, 3 insertions, 0 deletions
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