Skip to content

Commit

Permalink
TC: don't report remainder of block for variable declaration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bacam committed Jan 14, 2025
1 parent 46e755d commit df5daa5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/lib/ast_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/lib/ast_util.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/type_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df5daa5

Please sign in to comment.