Skip to content

Commit 6d78c58

Browse files
authored
Drop Caml runtimes and primitives (#6984)
* remove Caml io/formatting/converting stuffs * remove Lexing/Parsing/Parser completely * remove Caml_sys completely * remove hash/digest/Hashtbl * format jscomp/test again * restore Hashtbl.hash * update lib artifacts * remove stale tests * remove Caml compile time constants * remove (almost) Caml String/Bytes/Char/Stream * remove floatarray * remove Caml int32/int64/nativeint * remove uint32 liternal which has never exposed * migrate caml_{type}_compare/min/max primitives * Drop OCaml `Array` module * drop other OCaml DS modules * fix hashtbl size hint * rename promise primitive * remove unused code * update artifacts * remove unused module * Drop `%lazy_force` primitive * remove unused code * remove/replace all remain `caml_*` primitives * Remove unwanted float primitives * remote unused/unnecessary exn primitives * migrate dict primitive * rename #import to %import * migrate obj and option primitives * migrate hash primitives * remove unused code path * remove unused internal primitives * migrate already ones from internal primitives * specialize every primitives in a path * drop/rename more interfaces * merge exn primitive modules * move curry primitive module * move util primitives * update artifacts * fix gentype test * add empty modules for core OCamlCompat * rename ref primitives * bring back a few primitives for Core compatibility * bring back error reporting on unknown #prim * add more compat * Js_runtime_modules -> Primitive_modules * Remove unused code path * Remove unused code path (floatarray) in frontend * remove unused builtin types * fix binding * refactor primitive externs * bring back Array module accessing pattern * more compat, deprecation, and migrate stdlib-406 dir completely * cleanup ninja dependencies Now the only `runtime` dir is the built-in primitive literally Removed dependency hacks from `ninja.js` and make the dependency graph clearly `others` -> `runtime` Removed `Belt_internals` module, use compiler primitive instead Removed `runtime/js`, so made `others/js` only source of JS bindings Primitives shouldn't rely on JS any binding * add deprecation on pervasives * tmp: try fix * clean a bit * added %modfloat primitive, added Pervasives.mod_float compat * added Pervasive string conversion compat * do not mention Js module * add clean-rewatch recipe
1 parent 9c4af76 commit 6d78c58

File tree

1,082 files changed

+10742
-107105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,082 files changed

+10742
-107105
lines changed

Makefile

+5-3
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,18 @@ checkformat:
8282
clean-gentype:
8383
make -C jscomp/gentype_tests/typescript-react-example clean
8484

85+
clean-rewatch:
86+
cargo clean --manifest-path rewatch/Cargo.toml && rm -f rewatch/rewatch
87+
8588
clean:
8689
dune clean
87-
cargo clean --manifest-path rewatch/Cargo.toml && rm -f rewatch/rewatch
8890
./scripts/ninja.js clean && rm -f ninja/ninja
8991

90-
clean-all: clean clean-gentype
92+
clean-all: clean clean-gentype clean-rewatch
9193

9294
dev-container:
9395
docker build -t rescript-dev-container docker
9496

9597
.DEFAULT_GOAL := build
9698

97-
.PHONY: build watch rewatch ninja bench dce test test-syntax test-syntax-roundtrip test-gentype test-all lib playground playground-cmijs playground-release artifacts format checkformat clean-gentype clean clean-all dev-container
99+
.PHONY: build watch rewatch ninja bench dce test test-syntax test-syntax-roundtrip test-gentype test-all lib playground playground-cmijs playground-release artifacts format checkformat clean-gentype clean-rewatch clean clean-all dev-container
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
We've found a bug for you!
3-
/.../fixtures/modules2.res:1:9-14
3+
/.../fixtures/modules2.res:1:9-19
44

5-
1 │ let b = List.b
5+
1 │ let b = Belt.List.b
66
2 │
77

8-
The value b can't be found in List
8+
The value b can't be found in Belt.List
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
We've found a bug for you!
3-
/.../fixtures/primitives7.res:3:24
3+
/.../fixtures/primitives7.res:3:23
44

55
1 │ /* Wanted list(float), found list(int) */
66
2 │ let a = list{1, 2, 3}
7-
3 │ List.map(n => n +. 2., a)
7+
3 │ a->Belt.List.map(n => n +. 2.)
88
4 │
99

10-
This has type: list<int>
11-
But this function argument is expecting: list<float>
12-
13-
The incompatible parts:
14-
int vs float
10+
This has type: int
11+
But it's being used with the +. operator, which works on: float
12+
13+
Floats and ints have their own mathematical operators. This means you cannot add a float and an int without converting between the two.
14+
15+
Possible solutions:
16+
- Ensure all values in this calculation has the type float. You can convert between floats and ints via Belt.Float.toInt and Belt.Int.fromFloat.
17+
- Change the operator to +, which works on int
1518

1619
You can convert int to float with Belt.Int.toFloat.
1720
If this is a literal, try a number with a trailing dot (e.g. 20.).

jscomp/build_tests/super_errors/expected/warnings3.res.expected

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
let b = List.b
1+
let b = Belt.List.b
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/* Wanted list(float), found list(int) */
22
let a = list{1, 2, 3}
3-
List.map(n => n +. 2., a)
3+
a->Belt.List.map(n => n +. 2.)

jscomp/build_tests/super_errors/fixtures/warnings3.res

-3
This file was deleted.

jscomp/core/j.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ and vident = Id of ident | Qualified of module_id * string option
6666
pattern match we can ignore the first one for simplicity
6767
for example
6868
{[
69-
Qualified (_, Runtime, Some "caml_int_compare")
69+
Qualified (_, Runtime, Some "compare")
7070
]}
7171
*)
7272

jscomp/core/js_analyzer.ml

-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
210210
| Length _ | Is_null_or_undefined _ | String_append _ | Typeof _ | Js_not _
211211
| Cond _ | FlatCall _ | New _ | Fun _ | Raw_js_code _ | Array _
212212
| Caml_block_tag _ | Object _ | Tagged_template _
213-
| Number (Uint _) ->
214-
false
215213
| Await _ -> false
216214
| Spread _ -> false
217215

jscomp/core/js_block_runtime.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
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 option_id = Ident.create_persistent Js_runtime_modules.option
25+
let option_id = Ident.create_persistent Primitive_modules.option
2626

27-
let curry_id = Ident.create_persistent Js_runtime_modules.curry
27+
let curry_id = Ident.create_persistent Primitive_modules.curry
2828

2929
let check_additional_id (x : J.expression) : Ident.t option =
3030
match x.expression_desc with

jscomp/core/js_dump.ml

+3-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module L = Js_dump_lit
7474

7575
module Curry_gen = struct
7676
let pp_curry_dot f =
77-
P.string f Js_runtime_modules.curry;
77+
P.string f Primitive_modules.curry;
7878
P.string f L.dot
7979

8080
let pp_optimize_curry (f : P.t) (len : int) =
@@ -642,7 +642,6 @@ and expression_desc cxt ~(level : int) f x : cxt =
642642
| Int { i; c = None } ->
643643
Int32.to_string i
644644
(* check , js convention with ocaml lexical convention *)
645-
| Uint i -> Format.asprintf "%lu" i
646645
| BigInt {positive; value} -> Format.asprintf "%sn" (Bigint_utils.to_string positive value)
647646
in
648647
let need_paren =
@@ -651,8 +650,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
651650
else
652651
level = 15 (* Parenthesize as well when followed by a dot. *)
653652
&& s.[0] <> 'I' (* Infinity *)
654-
&& s.[0] <> 'N'
655-
(* NaN *)
653+
&& s.[0] <> 'N' (* NaN *)
656654
in
657655
let action _ = P.string f s in
658656
if need_paren then P.paren f action else action ();
@@ -722,7 +720,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
722720
| Optional_block (e, identity) ->
723721
expression ~level cxt f
724722
(if identity then e
725-
else E.runtime_call Js_runtime_modules.option "some" [ e ])
723+
else E.runtime_call Primitive_modules.option "some" [ e ])
726724
| Caml_block (el, _, _, Blk_module fields) ->
727725
expression_desc cxt ~level f
728726
(Object (None,

0 commit comments

Comments
 (0)