Skip to content

Commit f57b40a

Browse files
committed
change matching approach
1 parent ee454c6 commit f57b40a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

jscomp/ml/translcore.ml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,10 +810,15 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
810810
wrap (Lprim (prim, argl, e.exp_loc))
811811
))
812812
| Texp_apply
813-
( {exp_desc = Texp_ident (p, _, _)},
813+
( {
814+
exp_desc =
815+
Texp_ident
816+
( Pdot (Pdot (Pident module_name, "Dict", _), "fromArray", _),
817+
_,
818+
_ );
819+
},
814820
[(_lbl, Some {exp_desc = Texp_array args})] )
815-
when Path.name p = "Js.Dict.fromArray"
816-
&& args_elgible_for_dict_inlining args ->
821+
when Ident.name module_name = "Js" && args_elgible_for_dict_inlining args ->
817822
let fields = Array.make (List.length args) "" in
818823
let args =
819824
args

jscomp/test/DictTests.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/DictTests.res

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,15 @@ let dictCreationCanBeInlined2 = Js.Dict._unsafe_create([
1313
("age", "what"),
1414
("more", "stuff"),
1515
])
16+
17+
open Js
18+
19+
let dictCreationCanBeInlined3 = Dict.fromArray([
20+
("name", "hello"),
21+
("age", "what"),
22+
("more", "stuff"),
23+
])
24+
25+
open Dict
26+
27+
let dictCreationCanBeInlined4 = fromArray([("name", "hello"), ("age", "what"), ("more", "stuff")])

0 commit comments

Comments
 (0)