From 9bca1fc8e7f7910668149bab11664a6d2062b17f Mon Sep 17 00:00:00 2001 From: Alasdair Date: Wed, 17 Feb 2021 15:19:47 +0000 Subject: Check if an unbound identifier is bound as a function identifier Give a hint in the error message if this is the case --- src/type_check.ml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/type_check.ml b/src/type_check.ml index 1ada515e..a6a7f720 100644 --- a/src/type_check.ml +++ b/src/type_check.ml @@ -952,7 +952,7 @@ end = struct typ_debug (lazy ("get_val_spec: freshened to " ^ string_of_bind bind')); bind' with - | Not_found -> typ_error env (id_loc id) ("No val spec found for " ^ string_of_id id) + | Not_found -> typ_error env (id_loc id) ("No type declaration found for " ^ string_of_id id) let get_val_specs env = env.top_val_specs @@ -3883,7 +3883,10 @@ and infer_exp env (E_aux (exp_aux, (l, ())) as exp) = match Env.lookup_id v env with | Local (_, typ) | Enum typ -> annot_exp (E_id v) typ | Register (reff, _, typ) -> annot_exp_effect (E_id v) typ reff - | Unbound -> typ_error env l ("Identifier " ^ string_of_id v ^ " is unbound") + | Unbound -> + match Bindings.find_opt v (Env.get_val_specs env) with + | Some _ -> typ_error env l ("Identifier " ^ string_of_id v ^ " is unbound (Did you mean to call the " ^ string_of_id v ^ " function?)") + | None -> typ_error env l ("Identifier " ^ string_of_id v ^ " is unbound") end | E_lit lit -> annot_exp (E_lit lit) (infer_lit env lit) | E_sizeof nexp -> -- cgit v1.2.3