diff options
| author | Alasdair | 2021-02-17 15:19:47 +0000 |
|---|---|---|
| committer | Alasdair | 2021-02-17 15:19:47 +0000 |
| commit | 9bca1fc8e7f7910668149bab11664a6d2062b17f (patch) | |
| tree | dfb8b5a963503bdcb572d84f4c8424f6f047c401 | |
| parent | ad34dfb1fb20caf20241ccdfd406e4164484b3e1 (diff) | |
Check if an unbound identifier is bound as a function identifier
Give a hint in the error message if this is the case
| -rw-r--r-- | src/type_check.ml | 7 |
1 files changed, 5 insertions, 2 deletions
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 -> |
