diff options
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | typing/typecore.ml | 12 |
2 files changed, 12 insertions, 1 deletions
@@ -10,6 +10,7 @@ Bug fixes: - PR#5551: Avoid repeated lookups for missing cmi files - PR#5662: typo in md5.c - PR#5695: remove warnings on sparc code emitter +- PR#5697: better location for warnings on statement expressions Internals: - Moved debugger/envaux.ml to typing/envaux.ml to publish env_of_only_summary diff --git a/typing/typecore.ml b/typing/typecore.ml index 0a311e2dc..c5972ea71 100644 --- a/typing/typecore.ml +++ b/typing/typecore.ml @@ -988,6 +988,16 @@ let force_delayed_checks () = let fst3 (x, _, _) = x let snd3 (_, x, _) = x +let rec final_subexpression sexp = + match sexp.pexp_desc with + Pexp_let (_, _, e) + | Pexp_sequence (_, e) + | Pexp_try (e, _) + | Pexp_ifthenelse (_, e, _) + | Pexp_match (_, (_, e) :: _) + -> final_subexpression e + | _ -> sexp + (* Generalization criterion for expressions *) let rec is_nonexpansive exp = @@ -2699,7 +2709,7 @@ and type_construct env loc lid sarg explicit_arity ty_expected = (* Typing of statements (expressions whose values are discarded) *) and type_statement env sexp = - let loc = sexp.pexp_loc in + let loc = (final_subexpression sexp).pexp_loc in begin_def(); let exp = type_exp env sexp in end_def(); |