Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (42 sloc) 1.816 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (* CF mli *)
19
20 (* refactoring in progress *)
21
22 module Q = QmlAst
23
24 let expr gamma annotmap expr =
25 match expr with
26 | Q.Directive (_, `warncoerce, [e], [ty]) -> (
27 match QmlAnnotMap.find_ty_opt (Q.QAnnot.expr e) annotmap with
28 | None ->
29 let context = QmlError.Context.annoted_expr annotmap expr in
30 QmlError.i_error None context
31 "This expression has no annotation of type"
32 | Some annotty ->
33 let () =
b12589b @fpessaux [feature] Typer: Height of type abbreviation to balance unwinding during...
fpessaux authored
34 let (ty, _) = QmlTypes.type_of_type gamma ty in
fccc685 Initial open-source release
MLstate authored
35 if not (QmlMoreTypes.equal_ty ~gamma ty annotty) then
36 let context = QmlError.Context.annoted_expr annotmap expr in
37 QmlError.warning ~wclass:QmlTyperWarnings.warncoerce context (
38 "This expression should have type @{<bright>%a@}@\n"^^
39 "but has there type @{<bright>%a@}"
40 )
41 QmlPrint.pp#ty ty
42 QmlPrint.pp#ty annotty
43 in
44 ()
45 )
46 | _ -> ()
47
48 let process_code gamma annotmap code =
49 if WarningClass.is_warn QmlTyperWarnings.warncoerce then
50 QmlAstWalk.CodeExpr.iter (QmlAstWalk.Expr.iter (expr gamma annotmap)) code
Something went wrong with that request. Please try again.