diff --git a/src/lib/ast_util.ml b/src/lib/ast_util.ml index 5e2ddbe43..955a27981 100644 --- a/src/lib/ast_util.ml +++ b/src/lib/ast_util.ml @@ -176,6 +176,8 @@ let mpat_loc = function MP_aux (_, (l, _)) -> l let exp_loc = function E_aux (_, (l, _)) -> l +let lexp_loc = function LE_aux (_, (l, _)) -> l + let nexp_loc = function Nexp_aux (_, l) -> l let constraint_loc = function NC_aux (_, l) -> l diff --git a/src/lib/ast_util.mli b/src/lib/ast_util.mli index abfa03db7..cf6bbef81 100644 --- a/src/lib/ast_util.mli +++ b/src/lib/ast_util.mli @@ -451,6 +451,7 @@ val typ_loc : typ -> Parse_ast.l val pat_loc : 'a pat -> Parse_ast.l val mpat_loc : 'a mpat -> Parse_ast.l val exp_loc : 'a exp -> Parse_ast.l +val lexp_loc : 'a lexp -> Parse_ast.l val nexp_loc : nexp -> Parse_ast.l val constraint_loc : n_constraint -> Parse_ast.l val def_loc : ('a, 'b) def -> Parse_ast.l diff --git a/src/lib/type_check.ml b/src/lib/type_check.ml index 9f8c800dd..721bf7521 100644 --- a/src/lib/type_check.ml +++ b/src/lib/type_check.ml @@ -2330,7 +2330,7 @@ let rec check_exp env (E_aux (exp_aux, (l, uannot)) as exp : uannot exp) (Typ_au in let checked_exp = crule check_exp env exp typ in annot_exp (E_var (lexp, bind, checked_exp)) typ - | Update -> typ_error l "var expression can only be used to declare new variables, not update them" + | Update -> typ_error (lexp_loc lexp) "var expression can only be used to declare new variables, not update them" end | E_internal_return exp, _ -> let checked_exp = crule check_exp env exp typ in