Skip to content

Commit 7e8b601

Browse files
authored
Remove caml_external_polyfill and the related behavior (e.g. ?primitive) (rescript-lang#6925)
1 parent 0036228 commit 7e8b601

25 files changed

+16
-1069
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- Remove support for `@bs.send.pipe`. This also removes all functions in `Js_typed_array` that rely on `@bs.send.pipe`. https://github.com/rescript-lang/rescript-compiler/pull/6858 https://github.com/rescript-lang/rescript-compiler/pull/6891
4141
- Remove deprecated `Js.Vector` and `Js.List`. https://github.com/rescript-lang/rescript-compiler/pull/6900
4242
- Remove support for `%time` extension. https://github.com/rescript-lang/rescript-compiler/pull/6924
43+
- Remove `caml_external_polyfill` module and the related behavior. https://github.com/rescript-lang/rescript-compiler/pull/6925
4344

4445
#### :bug: Bug Fix
4546

jscomp/common/bs_warnings.ml

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
let warn_missing_primitive loc txt =
26-
Location.prerr_warning loc (Bs_unimplemented_primitive txt)
27-
2825
let warn_literal_overflow loc =
2926
Location.prerr_warning loc Bs_integer_literal_overflow
3027

jscomp/common/bs_warnings.mli

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

25-
val warn_missing_primitive : Location.t -> string -> unit
26-
2725
val warn_literal_overflow : Location.t -> unit
2826

2927
val error_unescaped_delimiter : Location.t -> string -> unit

jscomp/core/js_exp_make.ml

-9
Original file line numberDiff line numberDiff line change
@@ -1344,14 +1344,5 @@ let neq_null_undefined_boolean ?comment (a : t) (b : t) =
13441344
| Null, Undefined _ | Undefined _, Null -> true_
13451345
| _ -> { expression_desc = Bin (NotEqEq, a, b); comment }
13461346

1347-
(** TODO: in the future add a flag
1348-
to set globalThis
1349-
*)
1350-
let resolve_and_apply (s : string) (args : t list) : t =
1351-
call ~info:Js_call_info.builtin_runtime_call
1352-
(runtime_call Js_runtime_modules.external_polyfill "resolve"
1353-
[ str (if s.[0] = '?' then String.sub s 1 (String.length s - 1) else s) ])
1354-
args
1355-
13561347
let make_exception (s : string) =
13571348
pure_runtime_call Js_runtime_modules.exceptions Literals.create [ str s ]

jscomp/core/js_exp_make.mli

-2
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,4 @@ val for_sure_js_null_undefined : J.expression -> bool
363363

364364
val is_null_undefined : ?comment:string -> t -> t
365365

366-
val resolve_and_apply : string -> t list -> t
367-
368366
val make_exception : string -> t

jscomp/core/lam_compile_primitive.ml

+1-4
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,4 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
400400
Lfunction(Curried, [parm],
401401
Matching.inline_lazy_force (Lvar parm) Location.none)
402402
It is inlined, this should not appear here *) ->
403-
(*we dont use [throw] here, since [throw] is an statement *)
404-
let s = Lam_print.primitive_to_string prim in
405-
Bs_warnings.warn_missing_primitive loc s;
406-
E.resolve_and_apply s args
403+
assert false

jscomp/core/lam_dispatch_primitive.ml

+4-10
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,7 @@ let translate loc (prim_name : string) (args : J.expression list) : J.expression
263263
| "?await" -> (
264264
match args with
265265
| [e] -> {e with expression_desc = Await e}
266-
| _ -> assert false
267-
)
268-
| _ ->
269-
Bs_warnings.warn_missing_primitive loc prim_name;
270-
E.resolve_and_apply prim_name args
271-
(*we dont use [throw] here, since [throw] is an statement
272-
so we wrap in IIFE
273-
TODO: we might provoide a hook for user to provide polyfill.
274-
For example `Bs_global.xxx`
275-
*)
266+
| _ -> assert false)
267+
| missing_impl ->
268+
let msg = Warnings.message (Bs_unimplemented_primitive missing_impl) in
269+
Location.raise_errorf ~loc "%s" msg

jscomp/ext/js_runtime_modules.ml

-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ let option = "Caml_option"
6565

6666
let module_ = "Caml_module"
6767

68-
let external_polyfill = "Caml_external_polyfill"
69-
7068
let caml_js_exceptions = "Caml_js_exceptions"
7169

7270
let caml_splice_call = "Caml_splice_call"

jscomp/ext/warnings.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ let message = function
485485
^ " : using an empty string as a shorthand to infer the external's name \
486486
from the value's name is dangerous when refactoring, and therefore \
487487
deprecated"
488-
| Bs_unimplemented_primitive s -> "Unimplemented primitive used:" ^ s
488+
| Bs_unimplemented_primitive s -> "Unimplemented primitive used: " ^ s
489489
| Bs_integer_literal_overflow ->
490490
"Integer literal exceeds the range of representable integers of type int"
491491
| Bs_uninterpreted_delimiters s -> "Uninterpreted delimiters " ^ s

jscomp/runtime/caml_external_polyfill.res

-51
This file was deleted.

jscomp/runtime/release.ninja

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ o runtime/caml_sys.cmj : cc_cmi runtime/caml_sys.res | runtime/caml_array_extern
5555
o runtime/caml_sys.cmi : cc runtime/caml_sys.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
5656
o runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj : cc runtime/caml_array_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
5757
o runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj : cc runtime/caml_bigint_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
58-
o runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj : cc runtime/caml_external_polyfill.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
5958
o runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj : cc runtime/caml_float_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6059
o runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj : cc runtime/caml_int64_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6160
o runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj : cc runtime/caml_js_exceptions.res | runtime/bs_stdlib_mini.cmi runtime/caml_exceptions.cmj runtime/js.cmi runtime/js.cmj
6261
o runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj : cc runtime/caml_nativeint_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6362
o runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj : cc runtime/caml_string_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6463
o runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj : cc runtime/caml_undefined_extern.res | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
6564
o runtime/curry.cmi runtime/curry.cmj : cc runtime/curry.res | runtime/bs_stdlib_mini.cmi runtime/caml_array.cmj runtime/caml_array_extern.cmj runtime/js.cmi runtime/js.cmj
66-
o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml.cmi runtime/caml.cmj runtime/caml_array.cmi runtime/caml_array.cmj runtime/caml_bigint.cmi runtime/caml_bigint.cmj runtime/caml_bytes.cmi runtime/caml_bytes.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_float.cmi runtime/caml_float.cmj runtime/caml_format.cmi runtime/caml_format.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_int32.cmi runtime/caml_int32.cmj runtime/caml_int64.cmi runtime/caml_int64.cmj runtime/caml_lexer.cmi runtime/caml_lexer.cmj runtime/caml_md5.cmi runtime/caml_md5.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_parser.cmi runtime/caml_parser.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_string.cmi runtime/caml_string.cmj runtime/caml_sys.cmi runtime/caml_sys.cmj runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj runtime/caml_external_polyfill.cmi runtime/caml_external_polyfill.cmj runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj
65+
o runtime : phony runtime/bs_stdlib_mini.cmi runtime/js.cmj runtime/js.cmi runtime/caml.cmi runtime/caml.cmj runtime/caml_array.cmi runtime/caml_array.cmj runtime/caml_bigint.cmi runtime/caml_bigint.cmj runtime/caml_bytes.cmi runtime/caml_bytes.cmj runtime/caml_exceptions.cmi runtime/caml_exceptions.cmj runtime/caml_float.cmi runtime/caml_float.cmj runtime/caml_format.cmi runtime/caml_format.cmj runtime/caml_hash.cmi runtime/caml_hash.cmj runtime/caml_hash_primitive.cmi runtime/caml_hash_primitive.cmj runtime/caml_int32.cmi runtime/caml_int32.cmj runtime/caml_int64.cmi runtime/caml_int64.cmj runtime/caml_lexer.cmi runtime/caml_lexer.cmj runtime/caml_md5.cmi runtime/caml_md5.cmj runtime/caml_module.cmi runtime/caml_module.cmj runtime/caml_obj.cmi runtime/caml_obj.cmj runtime/caml_option.cmi runtime/caml_option.cmj runtime/caml_parser.cmi runtime/caml_parser.cmj runtime/caml_splice_call.cmi runtime/caml_splice_call.cmj runtime/caml_string.cmi runtime/caml_string.cmj runtime/caml_sys.cmi runtime/caml_sys.cmj runtime/caml_array_extern.cmi runtime/caml_array_extern.cmj runtime/caml_bigint_extern.cmi runtime/caml_bigint_extern.cmj runtime/caml_float_extern.cmi runtime/caml_float_extern.cmj runtime/caml_int64_extern.cmi runtime/caml_int64_extern.cmj runtime/caml_js_exceptions.cmi runtime/caml_js_exceptions.cmj runtime/caml_nativeint_extern.cmi runtime/caml_nativeint_extern.cmj runtime/caml_string_extern.cmi runtime/caml_string_extern.cmj runtime/caml_undefined_extern.cmi runtime/caml_undefined_extern.cmj runtime/curry.cmi runtime/curry.cmj

jscomp/test/build.ninja

+1-4
Large diffs are not rendered by default.

jscomp/test/external_polyfill_test.js

-34
This file was deleted.

jscomp/test/external_polyfill_test.res

-17
This file was deleted.

jscomp/test/marshal.js

-68
This file was deleted.

jscomp/test/marshal.res

-68
This file was deleted.

jscomp/test/recursive_module.js

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/recursive_module.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module rec Int32: {
1515
module Xx: {
1616
let f: (int, int) => int
1717
} = {
18-
external f: (int, int) => int = "?hfiehi"
18+
external f: (int, int) => int = "hfiehi"
1919
}
2020

2121
let uuu = Xx.f

0 commit comments

Comments
 (0)