Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

When the payload of the ocaml.deprecated attribute is a string, repor…

…t it as part of the warning message.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14751 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
  • Loading branch information...
commit 110e97d4004a2dc14396d6de6c652e21f451e972 1 parent 85a1763
@alainfrisch alainfrisch authored
Showing with 18 additions and 8 deletions.
  1. +18 −8 typing/typetexp.ml
View
26 typing/typetexp.ml
@@ -55,15 +55,25 @@ type error =
exception Error of Location.t * Env.t * error
+let string_of_cst = function
+ | Const_string(s, _) -> Some s
+ | _ -> None
+
+let string_of_payload = function
+ | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] ->
+ string_of_cst c
+ | _ -> None
+
let check_deprecated loc attrs s =
- if
- List.exists
- (function
- | ({txt = "ocaml.deprecated"|"deprecated"; _}, _) -> true
- | _ -> false)
- attrs
- then
- Location.prerr_warning loc (Warnings.Deprecated s)
+ List.iter
+ (function
+ | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) ->
+ begin match string_of_payload p with
+ | Some txt -> Location.prerr_warning loc (Warnings.Deprecated (s ^ "\n" ^ txt))
+ | None -> Location.prerr_warning loc (Warnings.Deprecated s)
+ end
+ | _ -> ())
+ attrs
let warning_attribute attrs =
let prev_warnings = ref None in
Please sign in to comment.
Something went wrong with that request. Please try again.