Skip to content

Commit afdc6bf

Browse files
committed
raise instead of emulating Obj.magic
1 parent 0a50228 commit afdc6bf

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

jscomp/frontend/ast_exp_extension.ml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ let handle_extension e (self : Bs_ast_mapper.mapper)
2727
(({txt; loc}, payload) : Parsetree.extension) =
2828
match txt with
2929
| "todo" ->
30-
Location.prerr_warning e.Parsetree.pexp_loc
31-
(Bs_todo
32-
(match Ast_payload.is_single_string payload with
33-
| Some (s, _) -> Some s
34-
| None -> None));
30+
let todo_message =
31+
match Ast_payload.is_single_string payload with
32+
| Some (s, _) -> Some s
33+
| None -> None
34+
in
35+
Location.prerr_warning e.Parsetree.pexp_loc (Bs_todo todo_message);
3536
Exp.apply ~loc
36-
(Exp.ident ~loc {txt = Longident.parse "Obj.magic"; loc})
37-
[(Nolabel, Exp.construct ~loc {txt = Longident.Lident "()"; loc} None)]
37+
(Exp.ident ~loc {txt = Longident.parse "failwith"; loc})
38+
[
39+
( Nolabel,
40+
Exp.constant ~loc
41+
(Pconst_string
42+
( (match todo_message with
43+
| None -> "todo"
44+
| Some msg -> msg),
45+
None )) );
46+
]
3847
| "ffi" -> Ast_exp_handle_external.handle_ffi ~loc ~payload
3948
| "bs.raw" | "raw" ->
4049
Ast_exp_handle_external.handle_raw ~kind:Raw_exp loc payload

0 commit comments

Comments
 (0)