Skip to content

Commit 9b19074

Browse files
authored
Merge pull request #4545 from BuckleScript/disable_record_punning
fix #4535 disable record punning temporarily
2 parents 01f081c + 5834241 commit 9b19074

File tree

135 files changed

+2390
-2410
lines changed

Some content is hidden

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

135 files changed

+2390
-2410
lines changed

jscomp/core/js_dump.ml

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -940,49 +940,43 @@ and expression_desc cxt ~(level:int) f x : cxt =
940940
let cxt = P.group f 1 (fun _ -> expression ~level:3 cxt f e1) in
941941

942942
P.space f;
943-
P.string f L.colon;
944-
P.space f ;
943+
P.string f L.colon_space;
945944
(* idem *)
946945
P.group f 1 (fun _ -> expression ~level:3 cxt f e2)
947946
in
948947
if level > 2 then P.paren_vgroup f 1 action else action ()
949948

950-
| Object lst ->
951-
let action () =
952-
if lst = [] then begin P.string f "{}" ; cxt end else
953-
P.brace_vgroup f 1 (fun _ ->
954-
property_name_and_value_list cxt f lst) in
955-
if level > 1 then
949+
| Object lst ->
956950
(* #1946 object literal is easy to be
957951
interpreted as block statement
958952
here we avoid parens in such case
959953
{[
960954
var f = { x : 2 , y : 2}
961955
]}
962956
*)
963-
P.paren_group f 1 action
964-
else action ()
957+
P.cond_paren_group f (level > 1 ) 1 (fun _ ->
958+
if lst = [] then begin P.string f "{}" ; cxt end else
959+
P.brace_vgroup f 1 (fun _ ->
960+
property_name_and_value_list cxt f lst)
961+
)
962+
965963

966964
and property_name_and_value_list cxt f (l : J.property_map) =
967965
iter_lst cxt f l (fun cxt f (pn,e) ->
968966
match e.expression_desc with
969967
| Var (Id v | Qualified (v,_,None)) ->
970968
let key = Js_dump_property.property_key pn in
971969
let str, cxt = Ext_pp_scope.str_of_ident cxt v in
972-
if key = str then
973-
P.string f key
974-
else begin
975-
P.string f key;
976-
P.string f L.colon;
977-
P.space f;
978-
P.string f str ;
979-
end;
970+
let content =
971+
(* if key = str then key
972+
else *)
973+
key ^ L.colon_space ^ str in
974+
P.string f content ;
980975
cxt
981976
| _ ->
982977
let key = Js_dump_property.property_key pn in
983978
P.string f key;
984-
P.string f L.colon;
985-
P.space f;
979+
P.string f L.colon_space;
986980
expression ~level:1 cxt f e
987981
) comma_nl
988982

jscomp/core/js_dump_lit.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ let exports = "exports"
3838
let dot = "."
3939
let comma = ","
4040
let colon = Ext_string.single_colon
41+
let colon_space = ": "
4142
let throw = "throw"
4243
let default = "default"
4344
let length = "length"

jscomp/test/block_alias_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var v1 = {
3838

3939
var N = {
4040
Block: Block$1,
41-
v1
41+
v1: v1
4242
};
4343

4444
var Caml_obj$1 = {};

jscomp/test/caml_format_test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,13 +1850,13 @@ var string_of_lambda = Curry._1(Format.asprintf(/* Format */{
18501850
}), pr_lambda);
18511851

18521852
var Lambda_suites = {
1853-
ident,
1854-
kwd,
1855-
pr_exp0,
1856-
pr_app,
1857-
pr_other_applications,
1858-
pr_lambda,
1859-
string_of_lambda
1853+
ident: ident,
1854+
kwd: kwd,
1855+
pr_exp0: pr_exp0,
1856+
pr_app: pr_app,
1857+
pr_other_applications: pr_other_applications,
1858+
pr_lambda: pr_lambda,
1859+
string_of_lambda: string_of_lambda
18601860
};
18611861

18621862
var lambda_suites = [

jscomp/test/defunctor_make_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function Make(M) {
1111
}
1212

1313
var Comparable = {
14-
getcompare,
15-
Make
14+
getcompare: getcompare,
15+
Make: Make
1616
};
1717

1818
function height(param) {
@@ -143,7 +143,7 @@ function empty(v) {
143143
var compare = Caml_primitive.caml_int_compare;
144144

145145
var V0 = {
146-
compare
146+
compare: compare
147147
};
148148

149149
var compare$1 = Caml_primitive.caml_int_compare;

jscomp/test/demo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function ui_layout(compile, lookup, appContext) {
4949
var mk_titleRow = function (text) {
5050
return {
5151
label: {
52-
text
52+
text: text
5353
}
5454
};
5555
};
@@ -109,8 +109,8 @@ function ui_layout(compile, lookup, appContext) {
109109
var bid = price + 20 * Math.random();
110110
var ask = price + 20 * Math.random();
111111
var result = Curry._1(computeFunction.contents, {
112-
bid,
113-
ask
112+
bid: bid,
113+
ask: ask
114114
});
115115
return [
116116
mk_titleRow(param.ticker),

jscomp/test/demo_int_map.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function create(l, x, d, r) {
1313
var hl = height(l);
1414
var hr = height(r);
1515
return /* Node */{
16-
l,
16+
l: l,
1717
v: x,
18-
d,
19-
r,
18+
d: d,
19+
r: r,
2020
h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0
2121
};
2222
}
@@ -50,10 +50,10 @@ function bal(l, x, d, r) {
5050
}
5151
if (hr <= (hl + 2 | 0)) {
5252
return /* Node */{
53-
l,
53+
l: l,
5454
v: x,
55-
d,
56-
r,
55+
d: d,
56+
r: r,
5757
h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0
5858
};
5959
}
@@ -101,10 +101,10 @@ function add(x, data, m) {
101101
return m;
102102
} else {
103103
return /* Node */{
104-
l,
104+
l: l,
105105
v: x,
106106
d: data,
107-
r,
107+
r: r,
108108
h: m.h
109109
};
110110
}

jscomp/test/exception_alias.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var List$1 = {
6666
fast_sort: List.fast_sort,
6767
sort_uniq: List.sort_uniq,
6868
merge: List.merge,
69-
b,
69+
b: b,
7070
length: 3
7171
};
7272

jscomp/test/exception_rebind_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var Caml_exceptions = require("../../lib/js/caml_exceptions.js");
66
var E = Caml_exceptions.create("Exception_rebind_test.A.E");
77

88
var A = {
9-
E
9+
E: E
1010
};
1111

1212
var B = {

jscomp/test/extensible_variant_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var Str = Caml_exceptions.create("Extensible_variant_test.Str");
88
var Int = Caml_exceptions.create("Extensible_variant_test.N.Int");
99

1010
var N = {
11-
Int
11+
Int: Int
1212
};
1313

1414
var Int$1 = Caml_exceptions.create("Extensible_variant_test.Int");

0 commit comments

Comments
 (0)