Skip to content

Commit 65b47eb

Browse files
authored
Merge pull request #4137 from BuckleScript/dce
poor man global dead code analyzer
2 parents d92f9a0 + 4df23b8 commit 65b47eb

15 files changed

+7358
-7260
lines changed

.vscode/tasks.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,22 @@
5050
}
5151
]
5252
}
53+
},
54+
{
55+
"label": "check unused",
56+
"command" : "node",
57+
"options": {
58+
"cwd": "${workspaceRoot}/lib"
59+
},
60+
"args": [
61+
"../scripts/checkUnused.js"
62+
],
63+
"problemMatcher" :{
64+
"base": "$ocamlc",
65+
"fileLocation" :
66+
"autoDetect",
67+
"owner": "globalUnused"
68+
}
5369
}
5470
]
5571
}

jscomp/runtime/js.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ type +'a t
5252
]}
5353
*)
5454

55-
[@@@warning "-49"]
56-
(* internal types for FFI, these types are not used by normal users *)
55+
[@@@warning "-49"]
56+
(* internal types for FFI, these types are not used by normal users
57+
Absent cmi file when looking up module alias.
58+
*)
5759

5860
(**/**)
5961
module MapperRt = Js_mapperRt
@@ -65,7 +67,7 @@ module Internal = struct
6567
(** Js uncurried function *)
6668

6769
external (!) : 'a t -> 'a = "#unsafe_downgrade"
68-
external debugger : unit -> unit = "#debugger"
70+
6971
external unsafe_downgrade : 'a t -> 'a = "#unsafe_downgrade"
7072

7173
external fn_mk0 : (unit -> 'a0) -> (([`Arity_0], 'a0) fn) = "#fn_mk" "0"

jscomp/syntax/ast_util.ml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,13 @@ let to_method_callback =
293293
let handle_debugger loc (payload : Ast_payload.t) =
294294
match payload with
295295
| PStr [] ->
296-
Parsetree.Pexp_apply
297-
(Exp.ident {txt = Ldot(Ast_literal.Lid.js_internal, Literals.debugger ); loc},
298-
[ Nolabel, Ast_literal.val_unit ~loc ()])
296+
Ast_external_mk.local_external_apply
297+
loc
298+
~pval_prim:["#debugger"]
299+
~pval_type:(Typ.arrow Nolabel (Typ.any ())
300+
(Ast_literal.type_unit ())
301+
)
302+
[Ast_literal.val_unit ~loc ()]
299303
| _ ->
300304
Location.raise_errorf ~loc "bs.debugger does not accept payload"
301305

0 commit comments

Comments
 (0)