Skip to content

Commit 2af28f3

Browse files
authored
Merge pull request #4300 from BuckleScript/tweak
fix #4274
2 parents 0f8dec5 + af87256 commit 2af28f3

File tree

8 files changed

+84
-30
lines changed

8 files changed

+84
-30
lines changed

jscomp/syntax/ast_uncurry_gen.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper)
6262
)])
6363

6464
let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label) pat body
65+
: Parsetree.expression_desc
6566
=
6667
Bs_syntaxerr.optional_err loc label;
6768
let rec aux acc (body : Parsetree.expression) =
@@ -92,14 +93,11 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
9293
in
9394
Bs_syntaxerr.err_large_arity loc arity;
9495
let arity_s = string_of_int arity in
95-
Parsetree.Pexp_constraint(
96-
Exp.record ~loc [
96+
Pexp_record ([
9797
{
98-
txt = Ast_literal.Lid.hidden_field arity_s;
98+
txt = Ldot (Ast_literal.Lid.js_fn, "I" ^ arity_s);
9999
loc
100-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
101-
[Typ.any ~loc ()]
102-
)
100+
},body], None)
103101

104102

105103

jscomp/test/build.ninja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cm
320320
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
321321
build test/gpr_4069_test.cmi test/gpr_4069_test.cmj : cc test/gpr_4069_test.ml | $stdlib
322322
build test/gpr_4265_test.cmi test/gpr_4265_test.cmj : cc test/gpr_4265_test.ml | test/mt.cmj $stdlib
323+
build test/gpr_4274_test.cmi test/gpr_4274_test.cmj : cc test/gpr_4274_test.ml | $stdlib
323324
build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml | test/mt.cmj $stdlib
324325
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib
325326
build test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib

jscomp/test/gpr_4274_test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
var Belt_List = require("../../lib/js/belt_List.js");
4+
var Belt_Array = require("../../lib/js/belt_Array.js");
5+
6+
var N = { };
7+
8+
function f(X, xs) {
9+
return X.forEach(xs, {
10+
i: (function (x) {
11+
console.log(x.x);
12+
13+
})
14+
});
15+
}
16+
17+
Belt_List.forEachU(/* :: */[
18+
{
19+
x: 3
20+
},
21+
/* [] */0
22+
], (function (x) {
23+
console.log(x.x);
24+
25+
}));
26+
27+
var Foo = { };
28+
29+
var bar = [{
30+
foo: "bar"
31+
}];
32+
33+
Belt_Array.mapU(bar, (function (b) {
34+
return b.foo;
35+
}));
36+
37+
exports.N = N;
38+
exports.f = f;
39+
exports.Foo = Foo;
40+
exports.bar = bar;
41+
/* Not a pure module */

jscomp/test/gpr_4274_test.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module N = struct
2+
type t = { x : int}
3+
end
4+
5+
module type X = sig
6+
type 'a f = {i : 'a }
7+
val forEach : 'a array -> ('a -> unit) f -> unit [@bs]
8+
end
9+
10+
(* type annotation here interferes.. *)
11+
let f (module X : X) (xs : N.t array) =
12+
X.forEach xs ({ X.i = fun x -> Js.log x.x} ) [@bs]
13+
14+
15+
;; Belt.List.forEachU [{N.x=3}] (fun[@bs] x -> Js.log x.x)
16+
17+
18+
module Foo = struct type record = {
19+
foo: string;} end
20+
let bar = [|{ Foo.foo = (("bar")[@reason.raw_literal "bar"]) }|]
21+
22+
let _ = Belt.Array.mapU bar ((fun[@bs ] b -> b.foo))

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305991,6 +305991,7 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper)
305991305991
)])
305992305992

305993305993
let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label) pat body
305994+
: Parsetree.expression_desc
305994305995
=
305995305996
Bs_syntaxerr.optional_err loc label;
305996305997
let rec aux acc (body : Parsetree.expression) =
@@ -306021,14 +306022,11 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
306021306022
in
306022306023
Bs_syntaxerr.err_large_arity loc arity;
306023306024
let arity_s = string_of_int arity in
306024-
Parsetree.Pexp_constraint(
306025-
Exp.record ~loc [
306025+
Pexp_record ([
306026306026
{
306027-
txt = Ast_literal.Lid.hidden_field arity_s;
306027+
txt = Ldot (Ast_literal.Lid.js_fn, "I" ^ arity_s);
306028306028
loc
306029-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
306030-
[Typ.any ~loc ()]
306031-
)
306029+
},body], None)
306032306030

306033306031

306034306032

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305991,6 +305991,7 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper)
305991305991
)])
305992305992

305993305993
let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label) pat body
305994+
: Parsetree.expression_desc
305994305995
=
305995305996
Bs_syntaxerr.optional_err loc label;
305996305997
let rec aux acc (body : Parsetree.expression) =
@@ -306021,14 +306022,11 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
306021306022
in
306022306023
Bs_syntaxerr.err_large_arity loc arity;
306023306024
let arity_s = string_of_int arity in
306024-
Parsetree.Pexp_constraint(
306025-
Exp.record ~loc [
306025+
Pexp_record ([
306026306026
{
306027-
txt = Ast_literal.Lid.hidden_field arity_s;
306027+
txt = Ldot (Ast_literal.Lid.js_fn, "I" ^ arity_s);
306028306028
loc
306029-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
306030-
[Typ.any ~loc ()]
306031-
)
306029+
},body], None)
306032306030

306033306031

306034306032

lib/4.06.1/unstable/native_ppx.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21285,6 +21285,7 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper)
2128521285
)])
2128621286

2128721287
let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label) pat body
21288+
: Parsetree.expression_desc
2128821289
=
2128921290
Bs_syntaxerr.optional_err loc label;
2129021291
let rec aux acc (body : Parsetree.expression) =
@@ -21315,14 +21316,11 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
2131521316
in
2131621317
Bs_syntaxerr.err_large_arity loc arity;
2131721318
let arity_s = string_of_int arity in
21318-
Parsetree.Pexp_constraint(
21319-
Exp.record ~loc [
21319+
Pexp_record ([
2132021320
{
21321-
txt = Ast_literal.Lid.hidden_field arity_s;
21321+
txt = Ldot (Ast_literal.Lid.js_fn, "I" ^ arity_s);
2132221322
loc
21323-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
21324-
[Typ.any ~loc ()]
21325-
)
21323+
},body], None)
2132621324

2132721325

2132821326

lib/4.06.1/whole_compiler.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -410975,6 +410975,7 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper)
410975410975
)])
410976410976

410977410977
let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label) pat body
410978+
: Parsetree.expression_desc
410978410979
=
410979410980
Bs_syntaxerr.optional_err loc label;
410980410981
let rec aux acc (body : Parsetree.expression) =
@@ -411005,14 +411006,11 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
411005411006
in
411006411007
Bs_syntaxerr.err_large_arity loc arity;
411007411008
let arity_s = string_of_int arity in
411008-
Parsetree.Pexp_constraint(
411009-
Exp.record ~loc [
411009+
Pexp_record ([
411010411010
{
411011-
txt = Ast_literal.Lid.hidden_field arity_s;
411011+
txt = Ldot (Ast_literal.Lid.js_fn, "I" ^ arity_s);
411012411012
loc
411013-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
411014-
[Typ.any ~loc ()]
411015-
)
411013+
},body], None)
411016411014

411017411015

411018411016

0 commit comments

Comments
 (0)