Skip to content
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
6 changes: 3 additions & 3 deletions jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,21 @@ and pp_function is_method
*)
not is_method &&
Ext_list.for_all2_no_exn ls l is_var ->
let optimize len p cxt f v =
let optimize len ~p cxt f v =
if p then try_optimize_curry cxt f len function_id
else
vident cxt f v in
let len = List.length l in (* length *)
(match name with
| Name_top i | Name_non_top i ->
let cxt = pp_var_assign cxt f i in
let cxt = optimize len (arity = NA && len <= 8) cxt f v in
let cxt = optimize len ~p:(arity = NA && len <= 8) cxt f v in
semi f ;
cxt
| No_name ->
if return then
return_sp f ;
optimize len (arity = NA && len <=8) cxt f v)
optimize len ~p:(arity = NA && len <=8) cxt f v)

| _, _ ->
let set_env : Set_ident.t = (** identifiers will be printed following*)
Expand Down
21 changes: 21 additions & 0 deletions jscomp/syntax/bs_builtin_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,27 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
(s, (Some delim)))
->
Ast_utf8_string_interp.transform e s delim
| Pexp_array [] when
not (Ext_list.exists e.pexp_attributes (fun ({txt},_) -> txt = ""))->
(* `ocamlfind query ppx_tools`/dumpast -loc_underscore -e 'let emptyArray () = [||] in emptyArray ()'*)
let loc = e.pexp_loc in
let name = "emptyArray" in
let unit : _ Asttypes.loc = {txt = Ast_literal.Lid.val_unit ; loc } in
let open Ast_helper in
Exp.let_ Nonrecursive
[{pvb_pat =
Pat.var {txt = name ; loc} ~loc ;
pvb_expr =
Exp.fun_ Nolabel None
(Pat.construct unit None)
(Exp.array [] ~attrs:[{txt = ""; loc}, PStr []]);
pvb_loc = loc; pvb_attributes = []}]
(Exp.apply
(Exp.ident {txt = Lident name; loc})
[Nolabel,
Exp.construct unit None ~loc;
])

(** End rewriting *)
| Pexp_function cases ->
(* {[ function [@bs.exn]
Expand Down
Loading