Skip to content

Remove caml_external_polyfill and the related behavior (e.g. ?primitive) #6925

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- 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
- Remove deprecated `Js.Vector` and `Js.List`. https://github.com/rescript-lang/rescript-compiler/pull/6900
- Remove support for `%time` extension. https://github.com/rescript-lang/rescript-compiler/pull/6924
- Remove `caml_external_polyfill` module and the related behavior. https://github.com/rescript-lang/rescript-compiler/pull/6925

#### :bug: Bug Fix

Expand Down
3 changes: 0 additions & 3 deletions jscomp/common/bs_warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

let warn_missing_primitive loc txt =
Location.prerr_warning loc (Bs_unimplemented_primitive txt)

let warn_literal_overflow loc =
Location.prerr_warning loc Bs_integer_literal_overflow

Expand Down
2 changes: 0 additions & 2 deletions jscomp/common/bs_warnings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

val warn_missing_primitive : Location.t -> string -> unit

val warn_literal_overflow : Location.t -> unit

val error_unescaped_delimiter : Location.t -> string -> unit
9 changes: 0 additions & 9 deletions jscomp/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1344,14 +1344,5 @@ let neq_null_undefined_boolean ?comment (a : t) (b : t) =
| Null, Undefined _ | Undefined _, Null -> true_
| _ -> { expression_desc = Bin (NotEqEq, a, b); comment }

(** TODO: in the future add a flag
to set globalThis
*)
let resolve_and_apply (s : string) (args : t list) : t =
call ~info:Js_call_info.builtin_runtime_call
(runtime_call Js_runtime_modules.external_polyfill "resolve"
[ str (if s.[0] = '?' then String.sub s 1 (String.length s - 1) else s) ])
args

let make_exception (s : string) =
pure_runtime_call Js_runtime_modules.exceptions Literals.create [ str s ]
2 changes: 0 additions & 2 deletions jscomp/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,4 @@ val for_sure_js_null_undefined : J.expression -> bool

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

val resolve_and_apply : string -> t list -> t

val make_exception : string -> t
5 changes: 1 addition & 4 deletions jscomp/core/lam_compile_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,4 @@ let translate output_prefix loc (cxt : Lam_compile_context.t)
Lfunction(Curried, [parm],
Matching.inline_lazy_force (Lvar parm) Location.none)
It is inlined, this should not appear here *) ->
(*we dont use [throw] here, since [throw] is an statement *)
let s = Lam_print.primitive_to_string prim in
Bs_warnings.warn_missing_primitive loc s;
E.resolve_and_apply s args
assert false
14 changes: 4 additions & 10 deletions jscomp/core/lam_dispatch_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,7 @@ let translate loc (prim_name : string) (args : J.expression list) : J.expression
| "?await" -> (
match args with
| [e] -> {e with expression_desc = Await e}
| _ -> assert false
)
| _ ->
Bs_warnings.warn_missing_primitive loc prim_name;
E.resolve_and_apply prim_name args
(*we dont use [throw] here, since [throw] is an statement
so we wrap in IIFE
TODO: we might provoide a hook for user to provide polyfill.
For example `Bs_global.xxx`
*)
| _ -> assert false)
| missing_impl ->
let msg = Warnings.message (Bs_unimplemented_primitive missing_impl) in
Location.raise_errorf ~loc "%s" msg
2 changes: 0 additions & 2 deletions jscomp/ext/js_runtime_modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ let option = "Caml_option"

let module_ = "Caml_module"

let external_polyfill = "Caml_external_polyfill"

let caml_js_exceptions = "Caml_js_exceptions"

let caml_splice_call = "Caml_splice_call"
Expand Down
2 changes: 1 addition & 1 deletion jscomp/ext/warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ let message = function
^ " : using an empty string as a shorthand to infer the external's name \
from the value's name is dangerous when refactoring, and therefore \
deprecated"
| Bs_unimplemented_primitive s -> "Unimplemented primitive used:" ^ s
| Bs_unimplemented_primitive s -> "Unimplemented primitive used: " ^ s
| Bs_integer_literal_overflow ->
"Integer literal exceeds the range of representable integers of type int"
| Bs_uninterpreted_delimiters s -> "Uninterpreted delimiters " ^ s
Expand Down
51 changes: 0 additions & 51 deletions jscomp/runtime/caml_external_polyfill.res

This file was deleted.

3 changes: 1 addition & 2 deletions jscomp/runtime/release.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ o runtime/caml_sys.cmj : cc_cmi runtime/caml_sys.res | runtime/caml_array_extern
o runtime/caml_sys.cmi : cc runtime/caml_sys.resi | runtime/bs_stdlib_mini.cmi runtime/js.cmi runtime/js.cmj
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
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
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
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
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
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
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
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
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
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
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
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
5 changes: 1 addition & 4 deletions jscomp/test/build.ninja

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions jscomp/test/external_polyfill_test.js

This file was deleted.

17 changes: 0 additions & 17 deletions jscomp/test/external_polyfill_test.res

This file was deleted.

68 changes: 0 additions & 68 deletions jscomp/test/marshal.js

This file was deleted.

68 changes: 0 additions & 68 deletions jscomp/test/marshal.res

This file was deleted.

3 changes: 1 addition & 2 deletions jscomp/test/recursive_module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion jscomp/test/recursive_module.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module rec Int32: {
module Xx: {
let f: (int, int) => int
} = {
external f: (int, int) => int = "?hfiehi"
external f: (int, int) => int = "hfiehi"
}

let uuu = Xx.f
Expand Down
Loading