Skip to content

Drop Caml runtimes and primitives #6984

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 61 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b1e6dce
remove Caml io/formatting/converting stuffs
cometkim Aug 27, 2024
3239d8c
remove Lexing/Parsing/Parser completely
cometkim Aug 27, 2024
cc79430
remove Caml_sys completely
cometkim Aug 27, 2024
be09d3a
remove hash/digest/Hashtbl
cometkim Aug 27, 2024
f3d626e
format jscomp/test again
cometkim Aug 27, 2024
f574f7d
restore Hashtbl.hash
cometkim Aug 27, 2024
59746f5
update lib artifacts
cometkim Aug 27, 2024
75e30c4
remove stale tests
cometkim Aug 27, 2024
be60efc
remove Caml compile time constants
cometkim Aug 27, 2024
42a8ec7
remove (almost) Caml String/Bytes/Char/Stream
cometkim Aug 27, 2024
f8ba2ad
remove floatarray
cometkim Aug 27, 2024
be1b9d9
remove Caml int32/int64/nativeint
cometkim Sep 5, 2024
778e0b4
remove uint32 liternal which has never exposed
cometkim Sep 6, 2024
f70cf16
migrate caml_{type}_compare/min/max primitives
cometkim Sep 6, 2024
770e085
Drop OCaml `Array` module
cometkim Sep 8, 2024
2856654
drop other OCaml DS modules
cometkim Sep 8, 2024
12cfb6d
fix hashtbl size hint
cometkim Sep 8, 2024
587b790
rename promise primitive
cometkim Sep 8, 2024
4b8b0e0
remove unused code
cometkim Sep 8, 2024
ea7db4f
update artifacts
cometkim Sep 8, 2024
dfbe7a8
remove unused module
cometkim Sep 9, 2024
d995fb5
Drop `%lazy_force` primitive
cometkim Sep 9, 2024
10956a1
remove unused code
cometkim Sep 9, 2024
53aadd5
remove/replace all remain `caml_*` primitives
cometkim Sep 10, 2024
b1368b0
Remove unwanted float primitives
cometkim Sep 10, 2024
8d03ff5
remote unused/unnecessary exn primitives
cometkim Sep 12, 2024
f2a4b5b
migrate dict primitive
cometkim Sep 12, 2024
071e475
rename #import to %import
cometkim Sep 12, 2024
efc71be
migrate obj and option primitives
cometkim Sep 22, 2024
1c1697f
migrate hash primitives
cometkim Sep 22, 2024
6afedf9
remove unused code path
cometkim Sep 22, 2024
c395c12
remove unused internal primitives
cometkim Sep 22, 2024
65dc00a
migrate already ones from internal primitives
cometkim Sep 22, 2024
c409df8
specialize every primitives in a path
cometkim Sep 22, 2024
b2c3190
drop/rename more interfaces
cometkim Sep 22, 2024
374df82
merge exn primitive modules
cometkim Sep 22, 2024
a3a8f45
move curry primitive module
cometkim Sep 22, 2024
0f4d56e
move util primitives
cometkim Sep 22, 2024
67e2df4
update artifacts
cometkim Sep 22, 2024
acec61c
fix gentype test
cometkim Sep 22, 2024
59ba709
add empty modules for core OCamlCompat
cometkim Sep 22, 2024
0c1b57e
rename ref primitives
cometkim Sep 22, 2024
d0c8a47
bring back a few primitives for Core compatibility
cometkim Sep 22, 2024
b9b9757
bring back error reporting on unknown #prim
cometkim Sep 22, 2024
2d6438f
add more compat
cometkim Sep 22, 2024
d013585
Js_runtime_modules -> Primitive_modules
cometkim Sep 22, 2024
acaae4f
Remove unused code path
cometkim Sep 22, 2024
8362f1b
Remove unused code path (floatarray) in frontend
cometkim Sep 22, 2024
d8d7419
remove unused builtin types
cometkim Sep 22, 2024
1a5c2fb
fix binding
cometkim Sep 22, 2024
59911ad
refactor primitive externs
cometkim Sep 24, 2024
eb640dd
bring back Array module accessing pattern
cometkim Sep 24, 2024
fa90cee
more compat, deprecation, and migrate stdlib-406 dir completely
cometkim Sep 24, 2024
7642ebf
cleanup ninja dependencies
cometkim Sep 24, 2024
65813ad
add deprecation on pervasives
cometkim Sep 24, 2024
7c591f6
tmp: try fix
cometkim Sep 24, 2024
075493d
clean a bit
cometkim Sep 24, 2024
0142f10
added %modfloat primitive, added Pervasives.mod_float compat
cometkim Sep 25, 2024
3e2f715
added Pervasive string conversion compat
cometkim Sep 25, 2024
1fe36e0
do not mention Js module
cometkim Sep 25, 2024
dc06a5b
add clean-rewatch recipe
cometkim Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,18 @@ checkformat:
clean-gentype:
make -C jscomp/gentype_tests/typescript-react-example clean

clean-rewatch:
cargo clean --manifest-path rewatch/Cargo.toml && rm -f rewatch/rewatch

clean:
dune clean
cargo clean --manifest-path rewatch/Cargo.toml && rm -f rewatch/rewatch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep this. make clean should clean everything including the rewatch build.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then what's different with make clean-all?

It's inconvenient to rebuild rewatch every time I run make clean test. we can add make clean-rewatch

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is a good question. 😄 This Makefile has grown organically.

I guess it's also fine to have clean-rewatch and put that into clean-all, too.

./scripts/ninja.js clean && rm -f ninja/ninja

clean-all: clean clean-gentype
clean-all: clean clean-gentype clean-rewatch

dev-container:
docker build -t rescript-dev-container docker

.DEFAULT_GOAL := build

.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
.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 number Diff line number Diff line change
@@ -1,8 +1,8 @@

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

1 │ let b = List.b
1 │ let b = Belt.List.b
2 │

The value b can't be found in List
The value b can't be found in Belt.List
17 changes: 10 additions & 7 deletions jscomp/build_tests/super_errors/expected/primitives7.res.expected
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@

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

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

This has type: list<int>
But this function argument is expecting: list<float>

The incompatible parts:
int vs float
This has type: int
But it's being used with the +. operator, which works on: float

Floats and ints have their own mathematical operators. This means you cannot add a float and an int without converting between the two.

Possible solutions:
- 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.
- Change the operator to +, which works on int

You can convert int to float with Belt.Int.toFloat.
If this is a literal, try a number with a trailing dot (e.g. 20.).
34 changes: 0 additions & 34 deletions jscomp/build_tests/super_errors/expected/warnings3.res.expected

This file was deleted.

2 changes: 1 addition & 1 deletion jscomp/build_tests/super_errors/fixtures/modules2.res
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let b = List.b
let b = Belt.List.b
2 changes: 1 addition & 1 deletion jscomp/build_tests/super_errors/fixtures/primitives7.res
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* Wanted list(float), found list(int) */
let a = list{1, 2, 3}
List.map(n => n +. 2., a)
a->Belt.List.map(n => n +. 2.)
3 changes: 0 additions & 3 deletions jscomp/build_tests/super_errors/fixtures/warnings3.res

This file was deleted.

2 changes: 1 addition & 1 deletion jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ and vident = Id of ident | Qualified of module_id * string option
pattern match we can ignore the first one for simplicity
for example
{[
Qualified (_, Runtime, Some "caml_int_compare")
Qualified (_, Runtime, Some "compare")
]}
*)

Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
| Length _ | Is_null_or_undefined _ | String_append _ | Typeof _ | Js_not _
| Cond _ | FlatCall _ | New _ | Fun _ | Raw_js_code _ | Array _
| Caml_block_tag _ | Object _ | Tagged_template _
| Number (Uint _) ->
false
| Await _ -> false
| Spread _ -> false

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

let option_id = Ident.create_persistent Js_runtime_modules.option
let option_id = Ident.create_persistent Primitive_modules.option

let curry_id = Ident.create_persistent Js_runtime_modules.curry
let curry_id = Ident.create_persistent Primitive_modules.curry

let check_additional_id (x : J.expression) : Ident.t option =
match x.expression_desc with
Expand Down
8 changes: 3 additions & 5 deletions jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module L = Js_dump_lit

module Curry_gen = struct
let pp_curry_dot f =
P.string f Js_runtime_modules.curry;
P.string f Primitive_modules.curry;
P.string f L.dot

let pp_optimize_curry (f : P.t) (len : int) =
Expand Down Expand Up @@ -642,7 +642,6 @@ and expression_desc cxt ~(level : int) f x : cxt =
| Int { i; c = None } ->
Int32.to_string i
(* check , js convention with ocaml lexical convention *)
| Uint i -> Format.asprintf "%lu" i
| BigInt {positive; value} -> Format.asprintf "%sn" (Bigint_utils.to_string positive value)
in
let need_paren =
Expand All @@ -651,8 +650,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
else
level = 15 (* Parenthesize as well when followed by a dot. *)
&& s.[0] <> 'I' (* Infinity *)
&& s.[0] <> 'N'
(* NaN *)
&& s.[0] <> 'N' (* NaN *)
in
let action _ = P.string f s in
if need_paren then P.paren f action else action ();
Expand Down Expand Up @@ -722,7 +720,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
| Optional_block (e, identity) ->
expression ~level cxt f
(if identity then e
else E.runtime_call Js_runtime_modules.option "some" [ e ])
else E.runtime_call Primitive_modules.option "some" [ e ])
| Caml_block (el, _, _, Blk_module fields) ->
expression_desc cxt ~level f
(Object (None,
Expand Down
Loading