diff options
author | Alain Frisch <alain@frisch.fr> | 2012-07-24 08:57:52 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2012-07-24 08:57:52 +0000 |
commit | 504f620fc700c241b437dce87cf935c8b4f52592 (patch) | |
tree | a231f7ac0220aa5c3684230b5e3728f2454d0d23 | |
parent | 0e45ab396153ab2c3620acf7558b8583ff2bb91b (diff) |
#5697: better location for warnings on statement expressions.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12763 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-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(); |