summaryrefslogtreecommitdiff
path: root/lambda
diff options
context:
space:
mode:
authorFabian <copy@copy.sh>2022-01-15 23:28:04 -0600
committerFabian <copy@copy.sh>2022-07-25 17:30:54 +0900
commit7b90874b829368d85d6a4b80d96e0f3687b4d10f (patch)
treeffbb3e08ffbda8d2773e8fb74c8b67f89ef21923 /lambda
parenta9d4b4be7d17c843259b562e3a1a97eb9a012781 (diff)
downloadocaml-7b90874b829368d85d6a4b80d96e0f3687b4d10f.tar.gz
Improve the location reported by parenthesized assertions (#10852)
Extend the typedtree with a location field for assertions, which is taken from the location stack of the parsetree.
Diffstat (limited to 'lambda')
-rw-r--r--lambda/translcore.ml11
1 files changed, 5 insertions, 6 deletions
diff --git a/lambda/translcore.ml b/lambda/translcore.ml
index ba220958b8..0b58a23ae4 100644
--- a/lambda/translcore.ml
+++ b/lambda/translcore.ml
@@ -186,12 +186,11 @@ let event_function ~scopes exp lam =
(* Assertions *)
-let assert_failed ~scopes exp =
+let assert_failed loc ~scopes exp =
let slot =
transl_extension_path Loc_unknown
Env.initial Predef.path_assert_failure
in
- let loc = exp.exp_loc in
let (fname, line, char) =
Location.get_pos_info loc.Location.loc_start
in
@@ -547,13 +546,13 @@ and transl_exp0 ~in_new_scope ~scopes e =
transl_exp ~scopes body)
| Texp_pack modl ->
!transl_module ~scopes Tcoerce_none None modl
- | Texp_assert {exp_desc=Texp_construct(_, {cstr_name="false"}, _)} ->
- assert_failed ~scopes e
- | Texp_assert (cond) ->
+ | Texp_assert ({exp_desc=Texp_construct(_, {cstr_name="false"}, _)}, loc) ->
+ assert_failed loc ~scopes e
+ | Texp_assert (cond, loc) ->
if !Clflags.noassert
then lambda_unit
else Lifthenelse (transl_exp ~scopes cond, lambda_unit,
- assert_failed ~scopes e)
+ assert_failed loc ~scopes e)
| Texp_lazy e ->
(* when e needs no computation (constants, identifiers, ...), we
optimize the translation just as Lazy.lazy_from_val would