Skip to content

Remove obj keys mangle #6354

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 19, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

- `rescript build` will always build its dependency by default. The argument `-with-deps` is not needed anymore. https://github.com/rescript-lang/rescript-compiler/pull/6350

#### :boom: Breaking Change

- Stop mangling object field names. If you had objects with field names containing "__" or leading "_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript-compiler/pull/6354

#### :bug: Bug Fix

- Fixed outcome printer resolution of uncurried config. https://github.com/rescript-lang/rescript-compiler/pull/6353
Expand Down
148 changes: 0 additions & 148 deletions jscomp/common/lam_methname.ml

This file was deleted.

25 changes: 0 additions & 25 deletions jscomp/common/lam_methname.mli

This file was deleted.

7 changes: 3 additions & 4 deletions jscomp/core/lam_convert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,9 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) :
let setter = Ext_string.ends_with name Literals.setter_suffix in
let property =
if setter then
Lam_methname.translate
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else Lam_methname.translate name
(String.sub name 0
(String.length name - Literals.setter_suffix_len))
else name
in
prim
~primitive:(Pjs_unsafe_downgrade { name = property; setter })
Expand Down
25 changes: 9 additions & 16 deletions jscomp/frontend/ast_external_process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -406,29 +406,25 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
param_type :: arg_types,
result_types )
| Arg_cst _ ->
let s = Lam_methname.translate name in
( {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
( {obj_arg_label = External_arg_spec.obj_label name; obj_arg_type},
arg_types,
(* ignored in [arg_types], reserved in [result_types] *)
result_types )
| Nothing ->
let s = Lam_methname.translate name in
( {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
( {obj_arg_label = External_arg_spec.obj_label name; obj_arg_type},
param_type :: arg_types,
Parsetree.Otag ({Asttypes.txt = name; loc}, [], ty)
:: result_types )
| Int _ ->
let s = Lam_methname.translate name in
( {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
( {obj_arg_label = External_arg_spec.obj_label name; obj_arg_type},
param_type :: arg_types,
Otag
( {Asttypes.txt = name; loc},
[],
Ast_literal.type_int ~loc () )
:: result_types )
| Poly_var_string _ ->
let s = Lam_methname.translate name in
( {obj_arg_label = External_arg_spec.obj_label s; obj_arg_type},
( {obj_arg_label = External_arg_spec.obj_label name; obj_arg_type},
param_type :: arg_types,
Otag
( {Asttypes.txt = name; loc},
Expand All @@ -453,7 +449,6 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
param_type :: arg_types,
result_types )
| Nothing ->
let s = Lam_methname.translate name in
let for_sure_not_nested =
match ty.ptyp_desc with
| Ptyp_constr ({txt = Lident txt; _}, []) ->
Expand All @@ -462,7 +457,7 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
in
( {
obj_arg_label =
External_arg_spec.optional for_sure_not_nested s;
External_arg_spec.optional for_sure_not_nested name;
obj_arg_type;
},
param_type :: arg_types,
Expand All @@ -472,9 +467,8 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
Ast_comb.to_undefined_type loc ty )
:: result_types )
| Int _ ->
let s = Lam_methname.translate name in
( {
obj_arg_label = External_arg_spec.optional true s;
obj_arg_label = External_arg_spec.optional true name;
obj_arg_type;
},
param_type :: arg_types,
Expand All @@ -485,9 +479,8 @@ let process_obj (loc : Location.t) (st : external_desc) (prim_name : string)
@@ Ast_literal.type_int ~loc () )
:: result_types )
| Poly_var_string _ ->
let s = Lam_methname.translate name in
( {
obj_arg_label = External_arg_spec.optional true s;
obj_arg_label = External_arg_spec.optional true name;
obj_arg_type;
},
param_type :: arg_types,
Expand Down Expand Up @@ -961,7 +954,7 @@ let pval_prim_of_labels (labels : string Asttypes.loc list) =
([] : External_arg_spec.obj_params)
(fun p arg_kinds ->
let obj_arg_label =
External_arg_spec.obj_label (Lam_methname.translate p.txt)
External_arg_spec.obj_label (p.txt)
in
{obj_arg_type = Nothing; obj_arg_label} :: arg_kinds)
in
Expand All @@ -974,7 +967,7 @@ let pval_prim_of_option_labels (labels : (bool * string Asttypes.loc) list)
(if ends_with_unit then [External_arg_spec.empty_kind Extern_unit]
else [])
(fun (is_option, p) arg_kinds ->
let label_name = Lam_methname.translate p.txt in
let label_name = p.txt in
let obj_arg_label =
if is_option then External_arg_spec.optional false label_name
else External_arg_spec.obj_label label_name
Expand Down
2 changes: 1 addition & 1 deletion jscomp/test/class_type_ffi_test.js

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

12 changes: 6 additions & 6 deletions jscomp/test/gpr_1072.js

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

Loading