|
| 1 | +(* Js_of_ocaml compiler |
| 2 | + * http://www.ocsigen.org/js_of_ocaml/ |
| 3 | + * Copyright (C) 2019 Hugo Heuzard |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Lesser General Public License as published by |
| 7 | + * the Free Software Foundation, with linking exception; |
| 8 | + * either version 2.1 of the License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU Lesser General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU Lesser General Public License |
| 16 | + * along with this program; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | + *) |
| 19 | +open Util |
| 20 | + |
| 21 | +(* https://github.com/ocsigen/js_of_ocaml/issues/827 *) |
| 22 | + |
| 23 | +let%expect_test _ = |
| 24 | + let compile s = |
| 25 | + s |
| 26 | + |> Filetype.ocaml_text_of_string |
| 27 | + |> Filetype.write_ocaml |
| 28 | + |> compile_ocaml_to_cmo |
| 29 | + |> compile_cmo_to_javascript ~pretty:true |
| 30 | + |> fst |
| 31 | + |> parse_js |
| 32 | + in |
| 33 | + let program = |
| 34 | + compile |
| 35 | + {| |
| 36 | +[@@@ocaml.warning "-26-27"] |
| 37 | +let some_name () = |
| 38 | +try raise Not_found with |
| 39 | +| f -> |
| 40 | + (try fun g -> 0 with h -> fun h -> raise Not_found) |
| 41 | + (let o = |
| 42 | + ( try |
| 43 | + fun a -> |
| 44 | + try try fun c -> 0 with q -> raise (Not_found) with |
| 45 | + | f -> |
| 46 | + raise Not_found |
| 47 | + with |
| 48 | + | h -> |
| 49 | + (raise Not_found) ) |
| 50 | + () |
| 51 | + in |
| 52 | + try |
| 53 | + let m = try [] with j -> [] in |
| 54 | + true |
| 55 | + with |
| 56 | + | s -> |
| 57 | + true) |
| 58 | + |} |
| 59 | + in |
| 60 | + print_fun_decl program "some_name"; |
| 61 | + [%expect {| function some_name(param){try {throw Stdlib[8]}catch(_a_){return 0}} |}] |
0 commit comments