Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#### :boom: Breaking Change

- Remove the deprecated `Js` namespace and its runtime modules. https://github.com/rescript-lang/rescript/pull/8531

#### :eyeglasses: Spec Compliance

#### :rocket: New Feature
Expand Down
1 change: 0 additions & 1 deletion analysis/reanalyze/src/exn_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t =
("Error", stdlib_error);
("Exn", stdlib_exn);
("JsError", stdlib_js_error);
("Js.Json", [("parseExn", [js_exn])]);
("JSON", stdlib_json);
("Json_decode", bs_json);
("Json.Decode", bs_json);
Expand Down
6 changes: 3 additions & 3 deletions analysis/src/completion_front_end.ml
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ let complete_pipe_chain ~(in_jsx_context : bool) (exp : Parsetree.expression) =
(* Complete the end of pipe chains by reconstructing the pipe chain as a single pipe,
so it can be completed.
Example:
someArray->Js.Array2.filter(v => v > 10)->Js.Array2.map(v => v + 2)->
someArray->Array.filter(v => v > 10)->Array.map(v => v + 2)->
will complete as:
Js.Array2.map(someArray->Js.Array2.filter(v => v > 10), v => v + 2)->
Array.map(someArray->Array.filter(v => v > 10), v => v + 2)->
*)
match exp.pexp_desc with
(* When the left side of the pipe we're completing is a function application.
Example: someArray->Js.Array2.map(v => v + 2)-> *)
Example: someArray->Array.map(v => v + 2)-> *)
| Pexp_apply
{
funct = {pexp_desc = Pexp_ident {txt = Lident "->"}};
Expand Down
2 changes: 1 addition & 1 deletion compiler/core/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- printing

```ocaml
Js.log true
Console.log true
```

- pattern match
Expand Down
12 changes: 6 additions & 6 deletions compiler/core/destruct_exn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ However it does not prevent things like

```ocaml
destruct v begin fun exn ->
Js.log exn ;
Console.log exn ;
match exn with
| ..
| ..
Expand Down Expand Up @@ -44,7 +44,7 @@ Another proposal is
match%exn computation with
| A ..
| B ..
| Js.NonCamlOpenVariant ..
| JsExn ..
| v -> ..
```

Expand All @@ -53,7 +53,7 @@ Here we pack the data `v`
==>
```

match (Js_enx.internalTOOCamlException compuation) with
match (Primitive_exceptions.internalToException computation) with
| A ..
| B
| exception .. )
Expand All @@ -62,7 +62,7 @@ match (Js_enx.internalTOOCamlException compuation) with
The same problem is

```
match (Js_enx.internalTOOCamlException compuation) with
match (Primitive_exceptions.internalToException computation) with
| _ -> ..
```

Expand All @@ -76,6 +76,6 @@ Another very similar proposal would be
```ocaml
fun[@bs:exn] e ->
match e with
| Js.Exn.Error ..
| JsExn ..
| ..
```
```
4 changes: 2 additions & 2 deletions compiler/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ let lam_extension_id loc (head : Lam.t) =
]}
we approximate that if [id] is destructed or not.
If it is destructed, we need pack it in case it is JS exception.
The packing is called Js.Exn.internalTOOCamlException, which is a nop for OCaml exception,
The packing is called Primitive_exceptions.internalToException, which is a nop for OCaml exception,
but will wrap as (Error e) when it is an JS exception.
{[
try .. with
| A (x,y) ->
| Js.Error ..
| Exn.Error ..
]}
Without such wrapping, the code above would raise
Expand Down
20 changes: 0 additions & 20 deletions compiler/core/outcome_printer_ns.ml
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,6 @@ let ps = Format.pp_print_string
let out_ident ppf s =
ps ppf
(match s with
| "Js_null" -> "Js.Null"
| "Js_undefined" -> "Js.Undefined"
| "Js_null_undefined" -> "Js.Nullable"
| "Js_exn" -> "Js.Exn"
| "Js_array" -> "Js.Array"
| "Js_string" -> "Js.String"
| "Js_re" -> "Js.Re"
| "Js_promise" -> "Js.Promise"
| "Js_date" -> "Js.Date"
| "Js_dict" -> "Js.Dict"
| "Js_global" -> "Js.Global"
| "Js_json" -> "Js.Json"
| "Js_math" -> "Js.Math"
| "Js_obj" -> "Js.Obj"
| "Js_typed_array" -> "Js.Typed_array"
| "Js_types" -> "Js.Types"
| "Js_float" -> "Js.Float"
| "Js_int" -> "Js.Int"
| "Js_option" -> "Js.Option"
| "Js_result" -> "Js.Result"
(* Belt_libs *)
| "Belt_Id" -> "Belt.Id"
| "Belt_Array" -> "Belt.Array"
Expand Down
2 changes: 2 additions & 0 deletions compiler/ext/primitive_modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ let curry = "Primitive_curry"

let util = "Primitive_util"

let js_extern = "Primitive_js_extern"

let pervasives = "Pervasives"
2 changes: 1 addition & 1 deletion compiler/frontend/ast_core_type.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ val from_labels : loc:Location.t -> int -> string Asttypes.loc list -> t
(** return a function type
[from_labels ~loc tyvars labels]
example output:
{[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 > Js.t]}
{[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 >]}
*)

val make_obj : loc:Location.t -> Parsetree.object_field list -> t
Expand Down
44 changes: 0 additions & 44 deletions compiler/frontend/ast_exp_handle_external.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +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. *)

(**
{[
Js.undefinedToOption
(if Js.typeof x = "undefined" then undefined
else x )

]}

@deprecated
*)
let handle_external loc (x : string) : Parsetree.expression =
let raw_exp : Ast_exp.t =
let str_exp =
Ast_compatible.const_exp_string ~loc x ~delimiter:Ext_string.empty
in
{
str_exp with
pexp_desc =
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
~pval_type:
(Ast_helper.Typ.arrows
[{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}]
(Ast_helper.Typ.any ()))
[str_exp];
}
in
let empty =
(* FIXME: the empty delimiter does not make sense*)
Ast_helper.Exp.ident ~loc
{txt = Ldot (Ldot (Lident "Js", "Undefined"), "empty"); loc}
in
let undefined_typeof =
Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "undefinedToOption")}
in
let typeof = Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "typeof")} in

Ast_compatible.app1 ~loc undefined_typeof
(Ast_helper.Exp.ifthenelse ~loc
(Ast_compatible.app2 ~loc
(Ast_helper.Exp.ident ~loc {loc; txt = Lident "=="})
(Ast_compatible.app1 ~loc typeof raw_exp)
(Ast_compatible.const_exp_string ~loc "undefined"))
empty (Some raw_exp))

let handle_debugger loc (payload : Ast_payload.t) =
match payload with
| PStr [] ->
Expand Down
2 changes: 0 additions & 2 deletions compiler/frontend/ast_exp_handle_external.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 handle_external : Location.t -> string -> Parsetree.expression

val handle_debugger : Location.t -> Ast_payload.t -> Parsetree.expression_desc

val handle_ffi : loc:Location.t -> payload:Ast_payload.t -> Parsetree.expression
Expand Down
15 changes: 5 additions & 10 deletions compiler/frontend/ast_literal.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,19 @@ module Lid = struct

let pervasives : t = Lident Primitive_modules.pervasives

(* FIXME: Use primitive module *)
let js_oo : t = Lident "Js_OO"
let js_extern : t = Lident Primitive_modules.js_extern

(* FIXME: Use primitive module *)
let js_meth_callback : t = Ldot (js_oo, "Callback")
let method_callback : t = Ldot (js_extern, "Callback")

let ignore_id : t = Ldot (pervasives, "ignore")

let hidden_field n : t = Lident ("I" ^ n)

(* FIXME: Use primitive module *)
let js_null : t = Ldot (Lident "Js", "null")
let js_null : t = Ldot (Ldot (Lident "Stdlib", "Null"), "t")

(* FIXME: Use primitive module *)
let js_undefined : t = Ldot (Lident "Js", "undefined")
let js_undefined : t = Lident "undefined"

(* FIXME: Use primitive module *)
let js_null_undefined : t = Ldot (Lident "Js", "null_undefined")
let js_null_undefined : t = Ldot (Ldot (Lident "Stdlib", "Nullable"), "t")

let regexp_id : t = Ldot (Lident "Stdlib_RegExp", "t")
end
Expand Down
4 changes: 2 additions & 2 deletions compiler/frontend/ast_literal.mli
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ module Lid : sig

val pervasives : t

val js_oo : t
val js_extern : t

val js_meth_callback : t
val method_callback : t

val hidden_field : string -> t

Expand Down
2 changes: 1 addition & 1 deletion compiler/frontend/ast_typ_uncurry.ml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let to_method_callback_type loc (mapper : Bs_ast_mapper.mapper) ~arity
| Some n ->
Ast_helper.Typ.constr
{
txt = Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ string_of_int n);
txt = Ldot (Ast_literal.Lid.method_callback, "arity" ^ string_of_int n);
loc;
}
[meth_type]
Expand Down
14 changes: 2 additions & 12 deletions compiler/frontend/ast_typ_uncurry.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

(* Note that currently there is no way to consume [Js.meth_callback]
so it is fine to encode it with a freedom,
but we need make it better for error message.
- all are encoded as
{[
type fn = (`Args_n of _ , 'result ) Js.fn
type method = (`Args_n of _, 'result) Js.method
type method_callback = (`Args_n of _, 'result) Js.method_callback
]}
For [method_callback], the arity is never zero, so both [method]
and [fn] requires (unit -> 'a) to encode arity zero
*)
(* Method callbacks encode their arity with
[Primitive_js_extern.Callback.arityN]. The arity is never zero. *)

type typ = Parsetree.core_type

Expand Down
4 changes: 2 additions & 2 deletions compiler/frontend/ast_uncurry_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let to_method_callback ~async loc (self : Bs_ast_mapper.mapper) label
{
funct =
Exp.ident ~loc
{loc; txt = Ldot (Ast_literal.Lid.js_oo, "unsafe_to_method")};
{loc; txt = Ldot (Ast_literal.Lid.js_extern, "unsafe_to_method")};
args =
[
( Nolabel,
Expand All @@ -79,7 +79,7 @@ let to_method_callback ~async loc (self : Bs_ast_mapper.mapper) label
{
loc;
txt =
Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ arity_s);
Ldot (Ast_literal.Lid.method_callback, "arity" ^ arity_s);
}
[Typ.any ~loc ()]) );
];
Expand Down
2 changes: 1 addition & 1 deletion compiler/gentype/gentype_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ let sanitize_type_name name =
| '\'' -> '_'
| c -> c)
let unknown = ident "unknown"
let bigint_t = ident "BigInt"
let bigint_t = ident "bigint"
let boolean_t = ident "boolean"
let date_t = ident "Date"
let map_t (x, y) = ident ~type_args:[x; y] "Map"
Expand Down
11 changes: 0 additions & 11 deletions compiler/gentype/translate_structure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ let rec addAnnotationsToTypes_ ~config ~(expr : Typedtree.expression)
else a_name
in
{a_name; a_type} :: next_types1
| ( Texp_apply
{funct = {exp_desc = Texp_ident (path, _, _)}; args = [(_, Some expr1)]},
_,
_ ) -> (
match path |> Translate_type_expr_from_types.path_to_list |> List.rev with
| ["Js"; "Internal"; fn_mk]
when (* Uncurried function definition uses Js.Internal.fn_mkX(...) *)
String.length fn_mk >= 5
&& (String.sub fn_mk 0 5 [@doesNotRaise]) = "fn_mk" ->
arg_types |> addAnnotationsToTypes_ ~config ~expr:expr1
| _ -> arg_types)
| _ -> arg_types

and add_annotations_to_types ~config ~(expr : Typedtree.expression)
Expand Down
Loading
Loading