diff --git a/analysis/reanalyze/src/Arnold.ml b/analysis/reanalyze/src/Arnold.ml index e4dd423e2f..444c4d592e 100644 --- a/analysis/reanalyze/src/Arnold.ml +++ b/analysis/reanalyze/src/Arnold.ml @@ -534,7 +534,7 @@ module FindFunctionsCalled = struct let super = Tast_mapper.default in let expr (self : Tast_mapper.mapper) (e : Typedtree.expression) = (match e.exp_desc with - | Texp_apply ({exp_desc = Texp_ident (callee, _, _)}, _args) -> + | Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)}} -> let functionName = Path.name callee in callees := !callees |> StringSet.add functionName | _ -> ()); @@ -577,7 +577,10 @@ module ExtendFunctionTable = struct } -> Some (path, loc) | Some - {exp_desc = Texp_apply ({exp_desc = Texp_ident (path, {loc}, _)}, args)} + { + exp_desc = + Texp_apply {funct = {exp_desc = Texp_ident (path, {loc}, _)}; args}; + } when kindOpt <> None -> let checkArg ((argLabel : Asttypes.arg_label), _argOpt) = match (argLabel, kindOpt) with @@ -617,7 +620,7 @@ module ExtendFunctionTable = struct calls a progress function" functionName printPos id_pos; }))) - | Texp_apply ({exp_desc = Texp_ident (callee, _, _)}, args) + | Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)}; args} when callee |> FunctionTable.isInFunctionInTable ~functionTable -> let functionName = Path.name callee in args @@ -665,7 +668,8 @@ module CheckExpressionWellFormed = struct | Texp_ident (path, {loc}, _) -> checkIdent ~path ~loc; e - | Texp_apply ({exp_desc = Texp_ident (functionPath, _, _)}, args) -> + | Texp_apply {funct = {exp_desc = Texp_ident (functionPath, _, _)}; args} + -> let functionName = Path.name functionPath in args |> List.iter (fun ((argLabel : Asttypes.arg_label), argOpt) -> @@ -739,8 +743,10 @@ module Compile = struct match expr.exp_desc with | Texp_ident _ -> Command.nothing | Texp_apply - (({exp_desc = Texp_ident (calleeToRename, l, vd)} as expr), argsToExtend) - -> ( + { + funct = {exp_desc = Texp_ident (calleeToRename, l, vd)} as expr; + args = argsToExtend; + } -> ( let callee, args = match Hashtbl.find_opt ctx.innerRecursiveFunctions @@ -844,7 +850,8 @@ module Compile = struct and create a function call with the appropriate arguments *) assert false | None -> expr |> expression ~ctx |> evalArgs ~args ~ctx) - | Texp_apply (expr, args) -> expr |> expression ~ctx |> evalArgs ~args ~ctx + | Texp_apply {funct = expr; args} -> + expr |> expression ~ctx |> evalArgs ~args ~ctx | Texp_let ( Recursive, [{vb_pat = {pat_desc = Tpat_var (id, _); pat_loc}; vb_expr}], diff --git a/analysis/reanalyze/src/DeadValue.ml b/analysis/reanalyze/src/DeadValue.ml index 9e102cba52..9c07e696ae 100644 --- a/analysis/reanalyze/src/DeadValue.ml +++ b/analysis/reanalyze/src/DeadValue.ml @@ -126,13 +126,16 @@ let rec collectExpr super self (e : Typedtree.expression) = ValueReferences.add locTo.loc_start Location.none.loc_start) else addValueReference ~addFileReference:true ~locFrom ~locTo | Texp_apply - ( { - exp_desc = - Texp_ident - (path, _, {Types.val_loc = {loc_ghost = false; _} as locTo}); - exp_type; - }, - args ) -> + { + funct = + { + exp_desc = + Texp_ident + (path, _, {Types.val_loc = {loc_ghost = false; _} as locTo}); + exp_type; + }; + args; + } -> args |> processOptionalArgs ~expType:exp_type ~locFrom:(locFrom : Location.t) @@ -163,7 +166,10 @@ let rec collectExpr super self (e : Typedtree.expression) = { exp_desc = Texp_apply - ({exp_desc = Texp_ident (idArg2, _, _)}, args); + { + funct = {exp_desc = Texp_ident (idArg2, _, _)}; + args; + }; }; }; }; diff --git a/analysis/reanalyze/src/Exception.ml b/analysis/reanalyze/src/Exception.ml index 95bade64a9..891b2d6d4e 100644 --- a/analysis/reanalyze/src/Exception.ml +++ b/analysis/reanalyze/src/Exception.ml @@ -294,8 +294,10 @@ let traverseAst () = } :: !currentEvents | Texp_apply - ( {exp_desc = Texp_ident (atat, _, _)}, - [(_lbl1, Some {exp_desc = Texp_ident (callee, _, _)}); arg] ) + { + funct = {exp_desc = Texp_ident (atat, _, _)}; + args = [(_lbl1, Some {exp_desc = Texp_ident (callee, _, _)}); arg]; + } when (* raise @@ Exn(...) *) atat |> Path.name = "Pervasives.@@" && callee |> Path.name |> isRaise -> @@ -303,15 +305,17 @@ let traverseAst () = currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents; arg |> snd |> iterExprOpt self | Texp_apply - ( {exp_desc = Texp_ident (atat, _, _)}, - [arg; (_lbl1, Some {exp_desc = Texp_ident (callee, _, _)})] ) + { + funct = {exp_desc = Texp_ident (atat, _, _)}; + args = [arg; (_lbl1, Some {exp_desc = Texp_ident (callee, _, _)})]; + } when (* Exn(...) |> raise *) atat |> Path.name = "Pervasives.|>" && callee |> Path.name |> isRaise -> let exceptions = [arg] |> raiseArgs in currentEvents := {Event.exceptions; loc; kind = Raises} :: !currentEvents; arg |> snd |> iterExprOpt self - | Texp_apply (({exp_desc = Texp_ident (callee, _, _)} as e), args) -> + | Texp_apply {funct = {exp_desc = Texp_ident (callee, _, _)} as e; args} -> let calleeName = Path.name callee in if calleeName |> isRaise then let exceptions = args |> raiseArgs in diff --git a/analysis/reanalyze/src/SideEffects.ml b/analysis/reanalyze/src/SideEffects.ml index d356ac23ae..b668d1f9bc 100644 --- a/analysis/reanalyze/src/SideEffects.ml +++ b/analysis/reanalyze/src/SideEffects.ml @@ -26,7 +26,7 @@ let rec exprNoSideEffects (expr : Typedtree.expression) = | Texp_ident _ | Texp_constant _ -> true | Texp_construct (_, _, el) -> el |> List.for_all exprNoSideEffects | Texp_function _ -> true - | Texp_apply ({exp_desc = Texp_ident (path, _, _)}, args) + | Texp_apply {funct = {exp_desc = Texp_ident (path, _, _)}; args} when path |> pathIsWhitelistedForSideEffects -> args |> List.for_all (fun (_, eo) -> eo |> exprOptNoSideEffects) | Texp_apply _ -> false diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index ceebf92274..c9acc4955e 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -255,33 +255,43 @@ let rec exprToContextPathInner (e : Parsetree.expression) = | None -> None | Some contexPath -> Some (CPObj (contexPath, txt))) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [ - (_, lhs); - (_, {pexp_desc = Pexp_apply (d, args); pexp_loc; pexp_attributes}); - ] ) -> + { + funct = + { + pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}; + pexp_loc; + pexp_attributes; + }; + args = [(_, lhs); (_, {pexp_desc = Pexp_apply {funct = d; args}})]; + } -> (* Transform away pipe with apply call *) exprToContextPath { - pexp_desc = Pexp_apply (d, (Nolabel, lhs) :: args); + pexp_desc = Pexp_apply {funct = d; args = (Nolabel, lhs) :: args}; pexp_loc; pexp_attributes; } | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [(_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes})] - ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = + [ + (_, lhs); (_, {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes}); + ]; + } -> (* Transform away pipe with identifier *) exprToContextPath { pexp_desc = Pexp_apply - ( {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes}, - [(Nolabel, lhs)] ); + { + funct = {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes}; + args = [(Nolabel, lhs)]; + }; pexp_loc; pexp_attributes; } - | Pexp_apply (e1, args) -> ( + | Pexp_apply {funct = e1; args} -> ( match exprToContextPath e1 with | None -> None | Some contexPath -> Some (CPApply (contexPath, args |> List.map fst))) @@ -313,14 +323,18 @@ let completePipeChain (exp : Parsetree.expression) = (* When the left side of the pipe we're completing is a function application. Example: someArray->Js.Array2.map(v => v + 2)-> *) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [_; (_, {pexp_desc = Pexp_apply (d, _)})] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = [_; (_, {pexp_desc = Pexp_apply {funct = d}})]; + } -> exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, d.pexp_loc)) (* When the left side of the pipe we're completing is an identifier application. Example: someArray->filterAllTheGoodStuff-> *) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = [_; (_, {pexp_desc = Pexp_ident _; pexp_loc})]; + } -> exprToContextPath exp |> Option.map (fun ctxPath -> (ctxPath, pexp_loc)) | _ -> None @@ -1094,11 +1108,15 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor scope := oldScope); resetCurrentCtxPath oldCtxPath | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}}, - [ - (_, lhs); - (_, {pexp_desc = Pexp_extension _; pexp_loc = {loc_ghost = true}}); - ] ) + { + funct = + {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}}; + args = + [ + (_, lhs); + (_, {pexp_desc = Pexp_extension _; pexp_loc = {loc_ghost = true}}); + ]; + } when opLoc |> Loc.hasPos ~pos:posBeforeCursor -> (* Case foo-> when the parser adds a ghost expression to the rhs so the apply expression does not include the cursor *) @@ -1228,7 +1246,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor exprLoc = e.pexp_loc; })) | None -> ()) - | Pexp_apply ({pexp_desc = Pexp_ident compName}, args) + | Pexp_apply {funct = {pexp_desc = Pexp_ident compName}; args} when Res_parsetree_viewer.is_jsx_expression expr -> inJsxContext := true; let jsxProps = CompletionJsx.extractJsxProps ~compName ~args in @@ -1269,23 +1287,34 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor })) else iterateJsxProps ~iterator jsxProps | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [ - (_, lhs); - (_, {pexp_desc = Pexp_ident {txt = Longident.Lident id; loc}}); - ] ) + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = + [ + (_, lhs); + (_, {pexp_desc = Pexp_ident {txt = Longident.Lident id; loc}}); + ]; + } when loc |> Loc.hasPos ~pos:posBeforeCursor -> if Debug.verbose () then print_endline "[expr_iter] Case foo->id"; setPipeResult ~lhs ~id |> ignore | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}}, - [(_, lhs); _] ) + { + funct = + { + pexp_desc = + Pexp_ident {txt = Lident ("|." | "|.u"); loc = opLoc}; + }; + args = [(_, lhs); _]; + } when Loc.end_ opLoc = posCursor -> if Debug.verbose () then print_endline "[expr_iter] Case foo->"; setPipeResult ~lhs ~id:"" |> ignore | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [_; (_, {pexp_desc = Pexp_apply (funExpr, args)})] ) + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = [_; (_, {pexp_desc = Pexp_apply {funct = funExpr; args}})]; + } when (* Normally named arg completion fires when the cursor is right after the expression. E.g in foo(~<---there But it should not fire in foo(~a)<---there *) @@ -1318,10 +1347,13 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor resetCurrentCtxPath oldCtxPath) | Some argCompletable -> setResult argCompletable) | Pexp_apply - ({pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, [_; _]) -> + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = [_; _]; + } -> (* Ignore any other pipe. *) () - | Pexp_apply (funExpr, args) + | Pexp_apply {funct = funExpr; args} when not (Loc.end_ expr.pexp_loc = posCursor && charBeforeCursor = Some ')') -> ( diff --git a/analysis/src/DumpAst.ml b/analysis/src/DumpAst.ml index 00f9349704..b017a39e66 100644 --- a/analysis/src/DumpAst.ml +++ b/analysis/src/DumpAst.ml @@ -171,7 +171,7 @@ and printExprItem expr ~pos ~indentation = |> String.concat "\n") | Pexp_ident {txt} -> "Pexp_ident:" ^ (Utils.flattenLongIdent txt |> SharedTypes.ident) - | Pexp_apply (expr, args) -> + | Pexp_apply {funct = expr; args} -> let printLabel labelled ~pos = match labelled with | None -> "" diff --git a/analysis/src/SemanticTokens.ml b/analysis/src/SemanticTokens.ml index 6a82b5d98b..b1215e154d 100644 --- a/analysis/src/SemanticTokens.ml +++ b/analysis/src/SemanticTokens.ml @@ -247,7 +247,7 @@ let command ~debug ~emitter ~path = ~posEnd:(Some (Loc.end_ loc)) ~lid ~debug; Ast_iterator.default_iterator.expr iterator e - | Pexp_apply ({pexp_desc = Pexp_ident lident; pexp_loc}, args) + | Pexp_apply {funct = {pexp_desc = Pexp_ident lident; pexp_loc}; args} when Res_parsetree_viewer.is_jsx_expression e -> (* Angled brackets: @@ -299,11 +299,14 @@ let command ~debug ~emitter ~path = args |> List.iter (fun (_lbl, arg) -> iterator.expr iterator arg) | Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Lident (("<" | ">") as op); loc}; - }, - [_; _] ) -> + { + funct = + { + pexp_desc = + Pexp_ident {txt = Longident.Lident (("<" | ">") as op); loc}; + }; + args = [_; _]; + } -> if debug then Printf.printf "Binary operator %s %s\n" op (Loc.toString loc); emitter |> emitFromLoc ~loc ~type_:Operator; diff --git a/analysis/src/SignatureHelp.ml b/analysis/src/SignatureHelp.ml index 6aacb342c4..4b8c4f7f3d 100644 --- a/analysis/src/SignatureHelp.ml +++ b/analysis/src/SignatureHelp.ml @@ -364,16 +364,20 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads = | { pexp_desc = Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}, - [ - _; - ( _, - { - pexp_desc = - Pexp_apply (({pexp_desc = Pexp_ident _} as exp), args); - pexp_loc; - } ); - ] ); + { + funct = {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}}; + args = + [ + _; + ( _, + { + pexp_desc = + Pexp_apply + {funct = {pexp_desc = Pexp_ident _} as exp; args}; + pexp_loc; + } ); + ]; + }; } when locHasCursor pexp_loc -> let argAtCursor, extractedArgs = @@ -383,7 +387,8 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads = (exp.pexp_loc, `FunctionCall (argAtCursor, exp, extractedArgs)) (* Look for applying idents, like someIdent(...) *) | { - pexp_desc = Pexp_apply (({pexp_desc = Pexp_ident _} as exp), args); + pexp_desc = + Pexp_apply {funct = {pexp_desc = Pexp_ident _} as exp; args}; pexp_loc; } when locHasCursor pexp_loc -> diff --git a/analysis/src/Xform.ml b/analysis/src/Xform.ml index ada2f8e1ae..2077affb86 100644 --- a/analysis/src/Xform.ml +++ b/analysis/src/Xform.ml @@ -88,11 +88,15 @@ module IfThenElse = struct ( { pexp_desc = Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Lident (("=" | "<>") as op)}; - }, - [(Nolabel, arg1); (Nolabel, arg2)] ); + { + funct = + { + pexp_desc = + Pexp_ident + {txt = Longident.Lident (("=" | "<>") as op)}; + }; + args = [(Nolabel, arg1); (Nolabel, arg2)]; + }; }, e1, Some e2 ) diff --git a/compiler/frontend/ast_compatible.ml b/compiler/frontend/ast_compatible.ml index 7dcd98418f..707d0e9fdb 100644 --- a/compiler/frontend/ast_compatible.ml +++ b/compiler/frontend/ast_compatible.ml @@ -39,21 +39,23 @@ let apply_simple ?(loc = default_loc) ?(attrs = []) (fn : expression) pexp_loc = loc; pexp_attributes = attrs; pexp_desc = - Pexp_apply (fn, Ext_list.map args (fun x -> (Asttypes.Nolabel, x))); + Pexp_apply + {funct = fn; args = Ext_list.map args (fun x -> (Asttypes.Nolabel, x))}; } let app1 ?(loc = default_loc) ?(attrs = []) fn arg1 : expression = { pexp_loc = loc; pexp_attributes = attrs; - pexp_desc = Pexp_apply (fn, [(Nolabel, arg1)]); + pexp_desc = Pexp_apply {funct = fn; args = [(Nolabel, arg1)]}; } let app2 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 : expression = { pexp_loc = loc; pexp_attributes = attrs; - pexp_desc = Pexp_apply (fn, [(Nolabel, arg1); (Nolabel, arg2)]); + pexp_desc = + Pexp_apply {funct = fn; args = [(Nolabel, arg1); (Nolabel, arg2)]}; } let app3 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 arg3 : expression = @@ -61,7 +63,8 @@ let app3 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 arg3 : expression = pexp_loc = loc; pexp_attributes = attrs; pexp_desc = - Pexp_apply (fn, [(Nolabel, arg1); (Nolabel, arg2); (Nolabel, arg3)]); + Pexp_apply + {funct = fn; args = [(Nolabel, arg1); (Nolabel, arg2); (Nolabel, arg3)]}; } let fun_ ?(loc = default_loc) ?(attrs = []) ?(async = false) ~arity pat exp = @@ -101,7 +104,11 @@ let apply_labels ?(loc = default_loc) ?(attrs = []) fn pexp_loc = loc; pexp_attributes = attrs; pexp_desc = - Pexp_apply (fn, Ext_list.map args (fun (l, a) -> (Asttypes.Labelled l, a))); + Pexp_apply + { + funct = fn; + args = Ext_list.map args (fun (l, a) -> (Asttypes.Labelled l, a)); + }; } let label_arrow ?(loc = default_loc) ?(attrs = []) ~arity s a b : core_type = diff --git a/compiler/frontend/ast_exp_apply.ml b/compiler/frontend/ast_exp_apply.ml index e8107bbc9b..66202b207f 100644 --- a/compiler/frontend/ast_exp_apply.ml +++ b/compiler/frontend/ast_exp_apply.ml @@ -64,7 +64,7 @@ let sane_property_name_check loc s = (* match fn as *) let view_as_app (fn : exp) (s : string list) : app_pattern option = match fn.pexp_desc with - | Pexp_apply ({pexp_desc = Pexp_ident {txt = Lident op; _}}, args) + | Pexp_apply {funct = {pexp_desc = Pexp_ident {txt = Lident op; _}}; args} when Ext_list.has_string s op -> Some {op; loc = fn.pexp_loc; args = check_and_discard args} | _ -> None @@ -88,10 +88,10 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp = {f with pexp_desc = Pexp_variant (label, Some a); pexp_loc = e.pexp_loc} | Pexp_construct (ctor, None) -> {f with pexp_desc = Pexp_construct (ctor, Some a); pexp_loc = e.pexp_loc} - | Pexp_apply (fn1, args) -> + | Pexp_apply {funct = fn1; args} -> Bs_ast_invariant.warn_discarded_unused_attributes fn1.pexp_attributes; { - pexp_desc = Pexp_apply (fn1, (Nolabel, a) :: args); + pexp_desc = Pexp_apply {funct = fn1; args = (Nolabel, a) :: args}; pexp_loc = e.pexp_loc; pexp_attributes = e.pexp_attributes @ f.pexp_attributes; } @@ -107,12 +107,16 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp = fn with pexp_desc = Pexp_construct (ctor, Some bounded_obj_arg); } - | Pexp_apply (fn, args) -> + | Pexp_apply {funct = fn; args} -> Bs_ast_invariant.warn_discarded_unused_attributes fn.pexp_attributes; { Parsetree.pexp_desc = - Pexp_apply (fn, (Nolabel, bounded_obj_arg) :: args); + Pexp_apply + { + funct = fn; + args = (Nolabel, bounded_obj_arg) :: args; + }; pexp_attributes = []; pexp_loc = fn.pexp_loc; } diff --git a/compiler/frontend/ast_uncurry_gen.ml b/compiler/frontend/ast_uncurry_gen.ml index c055f530a7..41d2b2068d 100644 --- a/compiler/frontend/ast_uncurry_gen.ml +++ b/compiler/frontend/ast_uncurry_gen.ml @@ -51,20 +51,27 @@ let to_method_callback loc (self : Bs_ast_mapper.mapper) label let arity_s = string_of_int arity in Stack.pop Js_config.self_stack |> ignore; Parsetree.Pexp_apply - ( Exp.ident ~loc - {loc; txt = Ldot (Ast_literal.Lid.js_oo, "unsafe_to_method")}, - [ - ( Nolabel, - Exp.constraint_ ~loc - (Exp.record ~loc - [ - ({loc; txt = Ast_literal.Lid.hidden_field arity_s}, body, false); - ] - None) - (Typ.constr ~loc - { - loc; - txt = Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ arity_s); - } - [Typ.any ~loc ()]) ); - ] ) + { + funct = + Exp.ident ~loc + {loc; txt = Ldot (Ast_literal.Lid.js_oo, "unsafe_to_method")}; + args = + [ + ( Nolabel, + Exp.constraint_ ~loc + (Exp.record ~loc + [ + ( {loc; txt = Ast_literal.Lid.hidden_field arity_s}, + body, + false ); + ] + None) + (Typ.constr ~loc + { + loc; + txt = + Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ arity_s); + } + [Typ.any ~loc ()]) ); + ]; + } diff --git a/compiler/frontend/bs_ast_mapper.ml b/compiler/frontend/bs_ast_mapper.ml index 99742c849c..992e552cac 100644 --- a/compiler/frontend/bs_ast_mapper.ml +++ b/compiler/frontend/bs_ast_mapper.ml @@ -320,7 +320,7 @@ module E = struct fun_ ~loc ~attrs ~arity ~async lab (map_opt (sub.expr sub) def) (sub.pat sub p) (sub.expr sub e) - | Pexp_apply (e, l) -> + | Pexp_apply {funct = e; args = l} -> apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) | Pexp_match (e, pel) -> match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) diff --git a/compiler/gentype/TranslateStructure.ml b/compiler/gentype/TranslateStructure.ml index 982ea9de3d..3def28f4a8 100644 --- a/compiler/gentype/TranslateStructure.ml +++ b/compiler/gentype/TranslateStructure.ml @@ -18,8 +18,10 @@ let rec addAnnotationsToTypes_ ~config ~(expr : Typedtree.expression) else a_name in {a_name; a_type} :: next_types1 - | Texp_apply ({exp_desc = Texp_ident (path, _, _)}, [(_, Some expr1)]), _, _ - -> ( + | ( Texp_apply + {funct = {exp_desc = Texp_ident (path, _, _)}; args = [(_, Some expr1)]}, + _, + _ ) -> ( match path |> TranslateTypeExprFromTypes.path_to_list |> List.rev with | ["Js"; "Internal"; fn_mk] when (* Uncurried function definition uses Js.Internal.fn_mkX(...) *) diff --git a/compiler/ml/ast_helper.ml b/compiler/ml/ast_helper.ml index e9ddd8630b..7af27c9656 100644 --- a/compiler/ml/ast_helper.ml +++ b/compiler/ml/ast_helper.ml @@ -154,7 +154,7 @@ module Exp = struct let fun_ ?loc ?attrs ?(async = false) ~arity a b c d = mk ?loc ?attrs (Pexp_fun {arg_label = a; default = b; lhs = c; rhs = d; arity; async}) - let apply ?loc ?attrs a b = mk ?loc ?attrs (Pexp_apply (a, b)) + let apply ?loc ?attrs funct args = mk ?loc ?attrs (Pexp_apply {funct; args}) let match_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_match (a, b)) let try_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_try (a, b)) let tuple ?loc ?attrs a = mk ?loc ?attrs (Pexp_tuple a) diff --git a/compiler/ml/ast_iterator.ml b/compiler/ml/ast_iterator.ml index 4013ba4d29..667953f976 100644 --- a/compiler/ml/ast_iterator.ml +++ b/compiler/ml/ast_iterator.ml @@ -286,7 +286,7 @@ module E = struct iter_opt (sub.expr sub) def; sub.pat sub p; sub.expr sub e - | Pexp_apply (e, l) -> + | Pexp_apply {funct = e; args = l} -> sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l | Pexp_match (e, pel) -> diff --git a/compiler/ml/ast_mapper.ml b/compiler/ml/ast_mapper.ml index eb08e516f0..69c3586036 100644 --- a/compiler/ml/ast_mapper.ml +++ b/compiler/ml/ast_mapper.ml @@ -283,7 +283,7 @@ module E = struct fun_ ~loc ~attrs ~arity ~async lab (map_opt (sub.expr sub) def) (sub.pat sub p) (sub.expr sub e) - | Pexp_apply (e, l) -> + | Pexp_apply {funct = e; args = l} -> apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) | Pexp_match (e, pel) -> match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) diff --git a/compiler/ml/ast_mapper_to0.ml b/compiler/ml/ast_mapper_to0.ml index c23c292b9b..70a68a98d2 100644 --- a/compiler/ml/ast_mapper_to0.ml +++ b/compiler/ml/ast_mapper_to0.ml @@ -325,7 +325,7 @@ module E = struct ~attrs:(arity_to_attributes arity) (Location.mkloc (Longident.Lident "Function$") e.pexp_loc) (Some e)) - | Pexp_apply (e, l) -> + | Pexp_apply {funct = e; args = l} -> apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) | Pexp_match (e, pel) -> match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) diff --git a/compiler/ml/depend.ml b/compiler/ml/depend.ml index d7114db984..7688750242 100644 --- a/compiler/ml/depend.ml +++ b/compiler/ml/depend.ml @@ -221,7 +221,7 @@ let rec add_expr bv exp = | Pexp_fun {default = opte; lhs = p; rhs = e} -> add_opt add_expr bv opte; add_expr (add_pattern bv p) e - | Pexp_apply (e, el) -> + | Pexp_apply {funct = e; args = el} -> add_expr bv e; List.iter (fun (_, e) -> add_expr bv e) el | Pexp_match (e, pel) -> diff --git a/compiler/ml/parsetree.ml b/compiler/ml/parsetree.ml index d4a75b32e3..ac3362783e 100644 --- a/compiler/ml/parsetree.ml +++ b/compiler/ml/parsetree.ml @@ -242,7 +242,7 @@ and expression_desc = - "fun P1 P2 .. Pn -> E1" is represented as nested Pexp_fun. - "let f P = E" is represented using Pexp_fun. *) - | Pexp_apply of expression * (arg_label * expression) list + | Pexp_apply of {funct: expression; args: (arg_label * expression) list} (* E0 ~l1:E1 ... ~ln:En li can be empty (non labeled argument) or start with '?' (optional argument). diff --git a/compiler/ml/pprintast.ml b/compiler/ml/pprintast.ml index ea826c2689..cb746ccb41 100644 --- a/compiler/ml/pprintast.ml +++ b/compiler/ml/pprintast.ml @@ -519,7 +519,10 @@ and sugar_expr ctxt f e = else match e.pexp_desc with | Pexp_apply - ({pexp_desc = Pexp_ident {txt = id; _}; pexp_attributes = []; _}, args) + { + funct = {pexp_desc = Pexp_ident {txt = id; _}; pexp_attributes = []; _}; + args; + } when List.for_all (fun (lab, _) -> lab = Nolabel) args -> ( let print_indexop a path_prefix assign left right print_index indices rem_args = @@ -628,7 +631,7 @@ and expression ctxt f x = (* rec_flag rf *) pp f "@[<2>%a in@;<1 -2>%a@]" (bindings reset_ctxt) (rf, l) (expression ctxt) e - | Pexp_apply (e, l) -> ( + | Pexp_apply {funct = e; args = l} -> ( if not (sugar_expr ctxt f x) then match view_fixity_of_exp e with | `Infix s -> ( diff --git a/compiler/ml/printast.ml b/compiler/ml/printast.ml index b521072bb8..5a1e245637 100644 --- a/compiler/ml/printast.ml +++ b/compiler/ml/printast.ml @@ -250,7 +250,7 @@ and expression i ppf x = option i expression ppf eo; pattern i ppf p; expression i ppf e - | Pexp_apply (e, l) -> + | Pexp_apply {funct = e; args = l} -> line i ppf "Pexp_apply\n"; expression i ppf e; list i label_x_expression ppf l diff --git a/compiler/ml/printtyped.ml b/compiler/ml/printtyped.ml index 686caa4083..c6db39060d 100644 --- a/compiler/ml/printtyped.ml +++ b/compiler/ml/printtyped.ml @@ -295,7 +295,7 @@ and expression i ppf x = line i ppf "%a" Ident.print param; arg_label i ppf p; case i ppf case_ - | Texp_apply (e, l) -> + | Texp_apply {funct = e; args = l} -> line i ppf "Texp_apply\n"; expression i ppf e; list i label_x_expression ppf l diff --git a/compiler/ml/rec_check.ml b/compiler/ml/rec_check.ml index a669915a57..2c6512aba2 100644 --- a/compiler/ml/rec_check.ml +++ b/compiler/ml/rec_check.ml @@ -201,7 +201,8 @@ let rec classify_expression : Typedtree.expression -> sd = | Texp_pack _ | Texp_function _ | Texp_lazy _ | Texp_extension_constructor _ -> Static - | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, _) when is_ref vd -> Static + | Texp_apply {funct = {exp_desc = Texp_ident (_, _, vd)}} when is_ref vd -> + Static | Texp_apply _ | Texp_match _ | Texp_ifthenelse _ | Texp_send _ | Texp_field _ | Texp_assert _ | Texp_try _ | Texp_override _ -> Dynamic @@ -235,10 +236,11 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t = | Texp_constant _ -> Use.empty | Texp_new _ -> assert false | Texp_instvar _ -> Use.empty - | Texp_apply ({exp_desc = Texp_ident (_, _, vd)}, [(_, Some arg)]) + | Texp_apply + {funct = {exp_desc = Texp_ident (_, _, vd)}; args = [(_, Some arg)]} when is_ref vd -> Use.guard (expression env arg) - | Texp_apply (e, args) -> + | Texp_apply {funct = e; args} -> let arg env (_, eo) = option expression env eo in Use.(join (inspect (expression env e)) (inspect (list arg env args))) | Texp_tuple exprs -> Use.guard (list expression env exprs) diff --git a/compiler/ml/tast_iterator.ml b/compiler/ml/tast_iterator.ml index 62167ea372..941a8c421d 100644 --- a/compiler/ml/tast_iterator.ml +++ b/compiler/ml/tast_iterator.ml @@ -156,7 +156,7 @@ let expr sub {exp_extra; exp_desc; exp_env; _} = sub.value_bindings sub (rec_flag, list); sub.expr sub exp | Texp_function {case; _} -> sub.case sub case - | Texp_apply (exp, list) -> + | Texp_apply {funct = exp; args = list} -> sub.expr sub exp; List.iter (fun (_, o) -> Option.iter (sub.expr sub) o) list | Texp_match (exp, list1, list2, _) -> diff --git a/compiler/ml/tast_mapper.ml b/compiler/ml/tast_mapper.ml index 24541f60e8..22baed190d 100644 --- a/compiler/ml/tast_mapper.ml +++ b/compiler/ml/tast_mapper.ml @@ -202,9 +202,12 @@ let expr sub x = | Texp_function {arg_label; arity; param; case; partial; async} -> Texp_function {arg_label; arity; param; case = sub.case sub case; partial; async} - | Texp_apply (exp, list) -> + | Texp_apply {funct = exp; args = list} -> Texp_apply - (sub.expr sub exp, List.map (tuple2 id (opt (sub.expr sub))) list) + { + funct = sub.expr sub exp; + args = List.map (tuple2 id (opt (sub.expr sub))) list; + } | Texp_match (exp, cases, exn_cases, p) -> Texp_match (sub.expr sub exp, sub.cases sub cases, sub.cases sub exn_cases, p) diff --git a/compiler/ml/translcore.ml b/compiler/ml/translcore.ml index 73986b5d57..92a6f50e5a 100644 --- a/compiler/ml/translcore.ml +++ b/compiler/ml/translcore.ml @@ -711,11 +711,14 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = loc ) | None -> lambda) | Texp_apply - ( ({ - exp_desc = Texp_ident (_, _, {val_kind = Val_prim p}); - exp_type = prim_type; - } as funct), - oargs ) + { + funct = + { + exp_desc = Texp_ident (_, _, {val_kind = Val_prim p}); + exp_type = prim_type; + } as funct; + args = oargs; + } when List.length oargs >= p.prim_arity && List.for_all (fun (_, arg) -> arg <> None) oargs -> ( let args, args' = cut p.prim_arity oargs in @@ -757,7 +760,7 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda = | Plazyforce, [a] -> wrap (Matching.inline_lazy_force a e.exp_loc) | Plazyforce, _ -> assert false | _ -> wrap (Lprim (prim, argl, e.exp_loc)))) - | Texp_apply (funct, oargs) -> + | Texp_apply {funct; args = oargs} -> let inlined, funct = Translattribute.get_and_remove_inlined_attribute funct in diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 43d834a8e2..fa5ad4b639 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -139,7 +139,7 @@ let iter_expression f e = | Pexp_fun {default = eo; rhs = e} -> may expr eo; expr e - | Pexp_apply (e, lel) -> + | Pexp_apply {funct = e; args = lel} -> expr e; List.iter (fun (_, e) -> expr e) lel | Pexp_let (_, pel, e) -> @@ -1799,7 +1799,7 @@ let rec is_nonexpansive exp = List.for_all (fun vb -> is_nonexpansive vb.vb_expr) pat_exp_list && is_nonexpansive body | Texp_function _ -> true - | Texp_apply (e, (_, None) :: el) -> + | Texp_apply {funct = e; args = (_, None) :: el} -> is_nonexpansive e && List.for_all is_nonexpansive_opt (List.map snd el) | Texp_match (e, cases, [], _) -> is_nonexpansive e @@ -1834,12 +1834,15 @@ let rec is_nonexpansive exp = or the relaxed value restriction. See GPR#1142 *) | Texp_assert exp -> is_nonexpansive exp | Texp_apply - ( { - exp_desc = - Texp_ident - (_, _, {val_kind = Val_prim {Primitive.prim_name = "%raise"}}); - }, - [(Nolabel, Some e)] ) -> + { + funct = + { + exp_desc = + Texp_ident + (_, _, {val_kind = Val_prim {Primitive.prim_name = "%raise"}}); + }; + args = [(Nolabel, Some e)]; + } -> is_nonexpansive e | _ -> false @@ -2417,7 +2420,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp type_function ?in_function ~arity ~async loc sexp.pexp_attributes env ty_expected l [Ast_helper.Exp.case spat sbody] - | Pexp_apply (sfunct, sargs) -> + | Pexp_apply {funct = sfunct; args = sargs} -> assert (sargs <> []); begin_def (); (* one more level for non-returning functions *) @@ -2443,7 +2446,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg = Rejected) env sexp let mk_apply funct args = rue { - exp_desc = Texp_apply (funct, args); + exp_desc = Texp_apply {funct; args}; exp_loc = loc; exp_extra = []; exp_type = ty_res; diff --git a/compiler/ml/typedtree.ml b/compiler/ml/typedtree.ml index c3af7028fd..89df6ea32e 100644 --- a/compiler/ml/typedtree.ml +++ b/compiler/ml/typedtree.ml @@ -84,7 +84,10 @@ and expression_desc = partial: partial; async: bool; } - | Texp_apply of expression * (arg_label * expression option) list + | Texp_apply of { + funct: expression; + args: (arg_label * expression option) list; + } | Texp_match of expression * case list * case list * partial | Texp_try of expression * case list | Texp_tuple of expression list diff --git a/compiler/ml/typedtree.mli b/compiler/ml/typedtree.mli index 2aabedb4aa..b13b529b9d 100644 --- a/compiler/ml/typedtree.mli +++ b/compiler/ml/typedtree.mli @@ -148,7 +148,10 @@ and expression_desc = [Partial] if the pattern match is partial [Total] otherwise. *) - | Texp_apply of expression * (arg_label * expression option) list + | Texp_apply of { + funct: expression; + args: (arg_label * expression option) list; + } (** E0 ~l1:E1 ... ~ln:En The expression can be None if the expression is abstracted over diff --git a/compiler/ml/typedtreeIter.ml b/compiler/ml/typedtreeIter.ml index 74213d65a9..08c2bf1198 100644 --- a/compiler/ml/typedtreeIter.ml +++ b/compiler/ml/typedtreeIter.ml @@ -231,7 +231,7 @@ end = struct iter_bindings rec_flag list; iter_expression exp | Texp_function {case; _} -> iter_case case - | Texp_apply (exp, list) -> + | Texp_apply {funct = exp; args = list} -> iter_expression exp; List.iter (fun (_label, expo) -> diff --git a/compiler/syntax/src/jsx_v4.ml b/compiler/syntax/src/jsx_v4.ml index e4c853e31a..2423588087 100644 --- a/compiler/syntax/src/jsx_v4.ml +++ b/compiler/syntax/src/jsx_v4.ml @@ -791,10 +791,8 @@ let modified_binding_old binding = (* here's where we spelunk! *) spelunk_for_fun_expression return_expression (* let make = React.forwardRef((~prop) => ...) *) - | { - pexp_desc = - Pexp_apply (_wrapperExpression, [(Nolabel, inner_function_expression)]); - } -> + | {pexp_desc = Pexp_apply {args = [(Nolabel, inner_function_expression)]}} + -> spelunk_for_fun_expression inner_function_expression | { pexp_desc = Pexp_sequence (_wrapperExpression, inner_function_expression); @@ -871,7 +869,8 @@ let modified_binding ~binding_loc ~binding_pat_loc ~fn_name binding = (* let make = React.forwardRef((~prop) => ...) *) | { pexp_desc = - Pexp_apply (wrapper_expression, [(Nolabel, internal_expression)]); + Pexp_apply + {funct = wrapper_expression; args = [(Nolabel, internal_expression)]}; } -> let () = has_application := true in let _, _, exp = spelunk_for_fun_expression internal_expression in @@ -1190,7 +1189,10 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name ~rec_flag binding = let make_new_binding ~loc ~full_module_name binding = let props_pattern = match binding.pvb_expr with - | {pexp_desc = Pexp_apply (wrapper_expr, [(Nolabel, func_expr)])} + | { + pexp_desc = + Pexp_apply {funct = wrapper_expr; args = [(Nolabel, func_expr)]}; + } when is_forward_ref wrapper_expr -> (* Case when using React.forwardRef *) let rec check_invalid_forward_ref expr = @@ -1505,7 +1507,7 @@ let expr ~config mapper expression = match expression with (* Does the function application have the @JSX attribute? *) | { - pexp_desc = Pexp_apply (call_expression, call_arguments); + pexp_desc = Pexp_apply {funct = call_expression; args = call_arguments}; pexp_attributes; pexp_loc; } -> ( diff --git a/compiler/syntax/src/res_ast_debugger.ml b/compiler/syntax/src/res_ast_debugger.ml index e72230596a..6013662403 100644 --- a/compiler/syntax/src/res_ast_debugger.ml +++ b/compiler/syntax/src/res_ast_debugger.ml @@ -570,7 +570,7 @@ module SexpAst = struct pattern pat; expression expr; ] - | Pexp_apply (expr, args) -> + | Pexp_apply {funct = expr; args} -> Sexp.list [ Sexp.atom "Pexp_apply"; diff --git a/compiler/syntax/src/res_comments_table.ml b/compiler/syntax/src/res_comments_table.ml index 9642a84626..4f40f7f151 100644 --- a/compiler/syntax/src/res_comments_table.ml +++ b/compiler/syntax/src/res_comments_table.ml @@ -327,7 +327,7 @@ let rec is_block_expr expr = | Pexp_letmodule _ | Pexp_letexception _ | Pexp_let _ | Pexp_open _ | Pexp_sequence _ -> true - | Pexp_apply (call_expr, _) when is_block_expr call_expr -> true + | Pexp_apply {funct = call_expr} when is_block_expr call_expr -> true | Pexp_constraint (expr, _) when is_block_expr expr -> true | Pexp_field (expr, _) when is_block_expr expr -> true | Pexp_setfield (expr, _, _) when is_block_expr expr -> true @@ -1314,33 +1314,40 @@ and walk_expression expr t comments = walk_list (cases |> List.map (fun case -> Case case)) t rest (* unary expression: todo use parsetreeviewer *) | Pexp_apply - ( { - pexp_desc = - Pexp_ident - { - txt = - Longident.Lident ("~+" | "~+." | "~-" | "~-." | "not" | "!"); - }; - }, - [(Nolabel, arg_expr)] ) -> + { + funct = + { + pexp_desc = + Pexp_ident + { + txt = + Longident.Lident ("~+" | "~+." | "~-" | "~-." | "not" | "!"); + }; + }; + args = [(Nolabel, arg_expr)]; + } -> let before, inside, after = partition_by_loc comments arg_expr.pexp_loc in attach t.leading arg_expr.pexp_loc before; walk_expression arg_expr t inside; attach t.trailing arg_expr.pexp_loc after (* binary expression *) | Pexp_apply - ( { - pexp_desc = - Pexp_ident - { - txt = - Longident.Lident - ( ":=" | "||" | "&&" | "=" | "==" | "<" | ">" | "!=" | "!==" - | "<=" | ">=" | "|>" | "+" | "+." | "-" | "-." | "++" | "^" - | "*" | "*." | "/" | "/." | "**" | "|." | "|.u" | "<>" ); - }; - }, - [(Nolabel, operand1); (Nolabel, operand2)] ) -> + { + funct = + { + pexp_desc = + Pexp_ident + { + txt = + Longident.Lident + ( ":=" | "||" | "&&" | "=" | "==" | "<" | ">" | "!=" + | "!==" | "<=" | ">=" | "|>" | "+" | "+." | "-" | "-." + | "++" | "^" | "*" | "*." | "/" | "/." | "**" | "|." + | "|.u" | "<>" ); + }; + }; + args = [(Nolabel, operand1); (Nolabel, operand2)]; + } -> let before, inside, after = partition_by_loc comments operand1.pexp_loc in attach t.leading operand1.pexp_loc before; walk_expression operand1 t inside; @@ -1354,25 +1361,43 @@ and walk_expression expr t comments = (* (List.concat [inside; after]); *) attach t.trailing operand2.pexp_loc after | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, - [(Nolabel, parent_expr); (Nolabel, member_expr)] ) -> + { + funct = + { + pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}; + }; + args = [(Nolabel, parent_expr); (Nolabel, member_expr)]; + } -> walk_list [Expression parent_expr; Expression member_expr] t comments | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}}, - [(Nolabel, parent_expr); (Nolabel, member_expr); (Nolabel, target_expr)] - ) -> + { + funct = + { + pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}; + }; + args = + [ + (Nolabel, parent_expr); + (Nolabel, member_expr); + (Nolabel, target_expr); + ]; + } -> walk_list [Expression parent_expr; Expression member_expr; Expression target_expr] t comments | Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Ldot (Lident "Primitive_dict", "make")}; - }, - [(Nolabel, key_values)] ) + { + funct = + { + pexp_desc = + Pexp_ident + {txt = Longident.Ldot (Lident "Primitive_dict", "make")}; + }; + args = [(Nolabel, key_values)]; + } when Res_parsetree_viewer.is_tuple_array key_values -> walk_list [Expression key_values] t comments - | Pexp_apply (call_expr, arguments) -> + | Pexp_apply {funct = call_expr; args = arguments} -> let before, inside, after = partition_by_loc comments call_expr.pexp_loc in let after = if is_block_expr call_expr then ( diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index 8c3095ebb0..3d7e0e1e72 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -2221,8 +2221,12 @@ and parse_binary_expr ?(context = OrdinaryExpr) ?a p prec = let loc = mk_loc a.Parsetree.pexp_loc.loc_start b.pexp_loc.loc_end in let expr = match (token, b.pexp_desc) with - | BarGreater, Pexp_apply (fun_expr, args) -> - {b with pexp_desc = Pexp_apply (fun_expr, args @ [(Nolabel, a)])} + | BarGreater, Pexp_apply {funct = fun_expr; args} -> + { + b with + pexp_desc = + Pexp_apply {funct = fun_expr; args = args @ [(Nolabel, a)]}; + } | BarGreater, _ -> Ast_helper.Exp.apply ~loc b [(Nolabel, a)] | _ -> Ast_helper.Exp.apply ~loc diff --git a/compiler/syntax/src/res_parens.ml b/compiler/syntax/src/res_parens.ml index af8b4b2160..3c87e6785e 100644 --- a/compiler/syntax/src/res_parens.ml +++ b/compiler/syntax/src/res_parens.ml @@ -152,12 +152,15 @@ let sub_binary_expr_operand parent_operator child_operator = let rhs_binary_expr_operand parent_operator rhs = match rhs.Parsetree.pexp_desc with | Parsetree.Pexp_apply - ( { - pexp_attributes = []; - pexp_desc = - Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; - }, - [(_, _left); (_, _right)] ) + { + funct = + { + pexp_attributes = []; + pexp_desc = + Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; + }; + args = [(_, _left); (_, _right)]; + } when ParsetreeViewer.is_binary_operator operator && not (operator_loc.loc_ghost && operator = "^") -> let prec_parent = ParsetreeViewer.operator_precedence parent_operator in @@ -168,11 +171,14 @@ let rhs_binary_expr_operand parent_operator rhs = let flatten_operand_rhs parent_operator rhs = match rhs.Parsetree.pexp_desc with | Parsetree.Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; - }, - [(_, _left); (_, _right)] ) + { + funct = + { + pexp_desc = + Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; + }; + args = [(_, _left); (_, _right)]; + } when ParsetreeViewer.is_binary_operator operator && not (operator_loc.loc_ghost && operator = "^") -> let prec_parent = ParsetreeViewer.operator_precedence parent_operator in @@ -201,7 +207,8 @@ let lazy_or_assert_or_await_expr_rhs ?(in_await = false) expr = Parenthesized | { pexp_desc = - Pexp_apply ({pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, _); + Pexp_apply + {funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}}; } when ParsetreeViewer.is_binary_expression expr -> if in_await && not (binary_operator_inside_await_needs_parens operator) diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index a2578e5ade..ea4d4c3354 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -79,13 +79,6 @@ let process_partial_app_attribute attrs = in process false [] attrs -let has_partial_attribute attrs = - List.exists - (function - | {Location.txt = "res.partial"}, _ -> true - | _ -> false) - attrs - let has_await_attribute attrs = List.exists (function @@ -136,7 +129,7 @@ let rewrite_underscore_apply expr = arg_label = Nolabel; default = None; lhs = {ppat_desc = Ppat_var {txt = "__x"}}; - rhs = {pexp_desc = Pexp_apply (call_expr, args)} as e; + rhs = {pexp_desc = Pexp_apply {funct = call_expr; args}} as e; } -> let new_args = List.map @@ -153,7 +146,7 @@ let rewrite_underscore_apply expr = | arg -> arg) args in - {e with pexp_desc = Pexp_apply (call_expr, new_args)} + {e with pexp_desc = Pexp_apply {funct = call_expr; args = new_args}} | _ -> expr type fun_param_kind = @@ -297,8 +290,10 @@ let is_unary_operator operator = let is_unary_expression expr = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, - [(Nolabel, _arg)] ) + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}; + args = [(Nolabel, _arg)]; + } when is_unary_operator operator -> true | _ -> false @@ -315,11 +310,14 @@ let is_binary_operator operator = let is_binary_expression expr = match expr.pexp_desc with | Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; - }, - [(Nolabel, _operand1); (Nolabel, _operand2)] ) + { + funct = + { + pexp_desc = + Pexp_ident {txt = Longident.Lident operator; loc = operator_loc}; + }; + args = [(Nolabel, _operand1); (Nolabel, _operand2)]; + } when is_binary_operator operator && not (operator_loc.loc_ghost && operator = "^") (* template literal *) -> @@ -386,8 +384,15 @@ let has_attributes attrs = let is_array_access expr = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, - [(Nolabel, _parentExpr); (Nolabel, _memberExpr)] ) -> + { + funct = + { + pexp_desc = + Pexp_ident + {txt = Longident.Ldot (Longident.Lident "Array", "get")}; + }; + args = [(Nolabel, _parentExpr); (Nolabel, _memberExpr)]; + } -> true | _ -> false @@ -516,8 +521,10 @@ let should_indent_binary_expr expr = | { pexp_desc = Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident sub_operator}}, - [(Nolabel, _lhs); (Nolabel, _rhs)] ); + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident sub_operator}}; + args = [(Nolabel, _lhs); (Nolabel, _rhs)]; + }; } when is_binary_operator sub_operator -> flattenable_operators operator sub_operator @@ -527,8 +534,10 @@ let should_indent_binary_expr expr = | { pexp_desc = Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, - [(Nolabel, lhs); (Nolabel, _rhs)] ); + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}; + args = [(Nolabel, lhs); (Nolabel, _rhs)]; + }; } when is_binary_operator operator -> is_equality_operator operator @@ -638,8 +647,10 @@ let has_tagged_template_literal_attr attrs = let is_template_literal expr = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "^"}}, - [(Nolabel, _); (Nolabel, _)] ) + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "^"}}; + args = [(Nolabel, _); (Nolabel, _)]; + } when has_template_literal_attr expr.pexp_attributes -> true | Pexp_constant (Pconst_string (_, Some "")) -> true @@ -707,15 +718,26 @@ let is_single_pipe_expr expr = let is_pipe_expr expr = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")}}, - [(Nolabel, _operand1); (Nolabel, _operand2)] ) -> + { + funct = + { + pexp_desc = + Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")}; + }; + args = [(Nolabel, _operand1); (Nolabel, _operand2)]; + } -> true | _ -> false in match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")}}, - [(Nolabel, operand1); (Nolabel, _operand2)] ) + { + funct = + { + pexp_desc = Pexp_ident {txt = Longident.Lident ("|." | "|.u" | "|>")}; + }; + args = [(Nolabel, operand1); (Nolabel, _operand2)]; + } when not (is_pipe_expr operand1) -> true | _ -> false diff --git a/compiler/syntax/src/res_parsetree_viewer.mli b/compiler/syntax/src/res_parsetree_viewer.mli index a8e4ee2fcf..30225de6a1 100644 --- a/compiler/syntax/src/res_parsetree_viewer.mli +++ b/compiler/syntax/src/res_parsetree_viewer.mli @@ -17,8 +17,6 @@ val functor_type : val process_partial_app_attribute : Parsetree.attributes -> bool * Parsetree.attributes -val has_partial_attribute : Parsetree.attributes -> bool - val has_await_attribute : Parsetree.attributes -> bool val has_res_pat_variant_spread_attribute : Parsetree.attributes -> bool val has_dict_pattern_attribute : Parsetree.attributes -> bool diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index 15a85b6345..d87f036bf8 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -3151,13 +3151,15 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl = Doc.text expr | extension -> print_extension ~state ~at_module_lvl:false extension cmt_tbl) - | Pexp_apply (e, [(Nolabel, {pexp_desc = Pexp_array sub_lists})]) + | Pexp_apply + {funct = e; args = [(Nolabel, {pexp_desc = Pexp_array sub_lists})]} when ParsetreeViewer.is_spread_belt_array_concat e -> print_belt_array_concat_apply ~state sub_lists cmt_tbl - | Pexp_apply (e, [(Nolabel, {pexp_desc = Pexp_array sub_lists})]) + | Pexp_apply + {funct = e; args = [(Nolabel, {pexp_desc = Pexp_array sub_lists})]} when ParsetreeViewer.is_spread_belt_list_concat e -> print_belt_list_concat_apply ~state sub_lists cmt_tbl - | Pexp_apply (call_expr, args) -> + | Pexp_apply {funct = call_expr; args} -> if ParsetreeViewer.is_unary_expression e then print_unary_expression ~state e cmt_tbl else if ParsetreeViewer.is_template_literal e then @@ -3560,8 +3562,10 @@ and print_template_literal ~state expr cmt_tbl = let open Parsetree in match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "^"}}, - [(Nolabel, arg1); (Nolabel, arg2)] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "^"}}; + args = [(Nolabel, arg1); (Nolabel, arg2)]; + } -> let lhs = walk_expr arg1 in let rhs = walk_expr arg2 in Doc.concat [lhs; rhs] @@ -3647,8 +3651,10 @@ and print_unary_expression ~state expr cmt_tbl = in match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, - [(Nolabel, operand)] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}; + args = [(Nolabel, operand)]; + } -> let printed_operand = let doc = print_expression_with_comments ~state operand cmt_tbl in match Parens.unary_expr_operand operand with @@ -3693,8 +3699,10 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl = | { pexp_desc = Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, - [(_, left); (_, right)] ); + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}; + args = [(_, left); (_, right)]; + }; } -> if ParsetreeViewer.flattenable_operators parent_operator operator @@ -3798,8 +3806,10 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl = else match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "^"; loc}}, - [(Nolabel, _); (Nolabel, _)] ) + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "^"; loc}}; + args = [(Nolabel, _); (Nolabel, _)]; + } when loc.loc_ghost -> let doc = print_template_literal ~state expr cmt_tbl in print_comments doc cmt_tbl expr.Parsetree.pexp_loc @@ -3810,8 +3820,10 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl = in if is_lhs then add_parens doc else doc | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "#="}}, - [(Nolabel, lhs); (Nolabel, rhs)] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "#="}}; + args = [(Nolabel, lhs); (Nolabel, rhs)]; + } -> let rhs_doc = print_expression_with_comments ~state rhs cmt_tbl in let lhs_doc = print_expression_with_comments ~state lhs cmt_tbl in (* TODO: unify indentation of "=" *) @@ -3846,11 +3858,14 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl = in match expr.pexp_desc with | Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Lident (("|." | "|.u" | "|>") as op)}; - }, - [(Nolabel, lhs); (Nolabel, rhs)] ) + { + funct = + { + pexp_desc = + Pexp_ident {txt = Longident.Lident (("|." | "|.u" | "|>") as op)}; + }; + args = [(Nolabel, lhs); (Nolabel, rhs)]; + } when not (ParsetreeViewer.is_binary_expression lhs || ParsetreeViewer.is_binary_expression rhs @@ -3873,8 +3888,10 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl = rhs_doc; ]) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}, - [(Nolabel, lhs); (Nolabel, rhs)] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident operator}}; + args = [(Nolabel, lhs); (Nolabel, rhs)]; + } -> let is_multiline = lhs.pexp_loc.loc_start.pos_lnum < rhs.pexp_loc.loc_start.pos_lnum in @@ -4043,8 +4060,10 @@ and print_belt_list_concat_apply ~state sub_lists cmt_tbl = and print_pexp_apply ~state expr cmt_tbl = match expr.pexp_desc with | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "##"}}, - [(Nolabel, parent_expr); (Nolabel, member_expr)] ) -> + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "##"}}; + args = [(Nolabel, parent_expr); (Nolabel, member_expr)]; + } -> let parent_doc = let doc = print_expression_with_comments ~state parent_expr cmt_tbl in match Parens.unary_expr_operand parent_expr with @@ -4073,8 +4092,10 @@ and print_pexp_apply ~state expr cmt_tbl = Doc.rbracket; ]) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Lident "#="}}, - [(Nolabel, lhs); (Nolabel, rhs)] ) -> ( + { + funct = {pexp_desc = Pexp_ident {txt = Longident.Lident "#="}}; + args = [(Nolabel, lhs); (Nolabel, rhs)]; + } -> ( let rhs_doc = let doc = print_expression_with_comments ~state rhs cmt_tbl in match Parens.expr rhs with @@ -4103,11 +4124,15 @@ and print_pexp_apply ~state expr cmt_tbl = | attrs -> Doc.group (Doc.concat [print_attributes ~state attrs cmt_tbl; doc])) | Pexp_apply - ( { - pexp_desc = - Pexp_ident {txt = Longident.Ldot (Lident "Primitive_dict", "make")}; - }, - [(Nolabel, key_values)] ) + { + funct = + { + pexp_desc = + Pexp_ident + {txt = Longident.Ldot (Lident "Primitive_dict", "make")}; + }; + args = [(Nolabel, key_values)]; + } when Res_parsetree_viewer.is_tuple_array key_values -> Doc.concat [ @@ -4116,8 +4141,13 @@ and print_pexp_apply ~state expr cmt_tbl = Doc.rbrace; ] | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}}, - [(Nolabel, parent_expr); (Nolabel, member_expr)] ) + { + funct = + { + pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "get")}; + }; + args = [(Nolabel, parent_expr); (Nolabel, member_expr)]; + } when not (ParsetreeViewer.is_rewritten_underscore_apply_sugar parent_expr) -> (* Don't print the Array.get(_, 0) sugar a.k.a. (__x) => Array.get(__x, 0) as _[0] *) @@ -4156,9 +4186,18 @@ and print_pexp_apply ~state expr cmt_tbl = Doc.rbracket; ]) | Pexp_apply - ( {pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}}, - [(Nolabel, parent_expr); (Nolabel, member_expr); (Nolabel, target_expr)] - ) -> + { + funct = + { + pexp_desc = Pexp_ident {txt = Longident.Ldot (Lident "Array", "set")}; + }; + args = + [ + (Nolabel, parent_expr); + (Nolabel, member_expr); + (Nolabel, target_expr); + ]; + } -> let member = let member_doc = let doc = print_expression_with_comments ~state member_expr cmt_tbl in @@ -4222,10 +4261,10 @@ and print_pexp_apply ~state expr cmt_tbl = else Doc.concat [Doc.space; target_expr]); ]) (* TODO: cleanup, are those branches even remotely performant? *) - | Pexp_apply ({pexp_desc = Pexp_ident lident}, args) + | Pexp_apply {funct = {pexp_desc = Pexp_ident lident}; args} when ParsetreeViewer.is_jsx_expression expr -> print_jsx_expression ~state lident args cmt_tbl - | Pexp_apply (call_expr, args) -> + | Pexp_apply {funct = call_expr; args} -> let args = List.map (fun (lbl, arg) -> (lbl, ParsetreeViewer.rewrite_underscore_apply arg)) @@ -4235,13 +4274,7 @@ and print_pexp_apply ~state expr cmt_tbl = let partial, attrs = ParsetreeViewer.process_partial_app_attribute attrs in let args = if partial then - let loc = - {Asttypes.txt = "res.partial"; Asttypes.loc = expr.pexp_loc} - in - let attr = (loc, Parsetree.PTyp (Ast_helper.Typ.any ())) in - let dummy = - Ast_helper.Exp.constant ~attrs:[attr] (Ast_helper.Const.int 0) - in + let dummy = Ast_helper.Exp.constant ~attrs (Ast_helper.Const.int 0) in args @ [(Asttypes.Labelled "...", dummy)] else args in @@ -4254,14 +4287,16 @@ and print_pexp_apply ~state expr cmt_tbl = in if ParsetreeViewer.requires_special_callback_printing_first_arg args then let args_doc = - print_arguments_with_callback_in_first_position ~state args cmt_tbl + print_arguments_with_callback_in_first_position ~state ~partial args + cmt_tbl in Doc.concat [print_attributes ~state attrs cmt_tbl; call_expr_doc; args_doc] else if ParsetreeViewer.requires_special_callback_printing_last_arg args then let args_doc = - print_arguments_with_callback_in_last_position ~state args cmt_tbl + print_arguments_with_callback_in_last_position ~state ~partial args + cmt_tbl in (* * Fixes the following layout (the `[` and `]` should break): @@ -4624,7 +4659,8 @@ and print_jsx_name {txt = lident} = let segments = flatten [] lident in Doc.join ~sep:Doc.dot segments -and print_arguments_with_callback_in_first_position ~state args cmt_tbl = +and print_arguments_with_callback_in_first_position ~state ~partial args cmt_tbl + = (* Because the same subtree gets printed twice, we need to copy the cmt_tbl. * consumed comments need to be marked not-consumed and reprinted… * Cheng's different comment algorithm will solve this. *) @@ -4684,7 +4720,9 @@ and print_arguments_with_callback_in_first_position ~state args cmt_tbl = * arg3, * ) *) - let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy) in + let break_all_args = + lazy (print_arguments ~state ~partial args cmt_tbl_copy) + in (* Sometimes one of the non-callback arguments will break. * There might be a single line comment in there, or a multiline string etc. @@ -4707,7 +4745,8 @@ and print_arguments_with_callback_in_first_position ~state args cmt_tbl = else Doc.custom_layout [Lazy.force fits_on_one_line; Lazy.force break_all_args] -and print_arguments_with_callback_in_last_position ~state args cmt_tbl = +and print_arguments_with_callback_in_last_position ~state ~partial args cmt_tbl + = (* Because the same subtree gets printed twice, we need to copy the cmt_tbl. * consumed comments need to be marked not-consumed and reprinted… * Cheng's different comment algorithm will solve this. *) @@ -4781,7 +4820,9 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl = * (param1, parm2) => doStuff(param1, parm2) * ) *) - let break_all_args = lazy (print_arguments ~state args cmt_tbl_copy2) in + let break_all_args = + lazy (print_arguments ~state ~partial args cmt_tbl_copy2) + in (* Sometimes one of the non-callback arguments will break. * There might be a single line comment in there, or a multiline string etc. @@ -4809,7 +4850,7 @@ and print_arguments_with_callback_in_last_position ~state args cmt_tbl = Lazy.force break_all_args; ] -and print_arguments ~state ?(partial = false) +and print_arguments ~state ~partial (args : (Asttypes.arg_label * Parsetree.expression) list) cmt_tbl = match args with | [ @@ -4839,16 +4880,8 @@ and print_arguments ~state ?(partial = false) Doc.concat [Doc.lparen; arg_doc; Doc.rparen] | args -> (* Avoid printing trailing comma when there is ... in function application *) - let has_partial_attr, printed_args = - List.fold_right - (fun arg (flag, acc) -> - let _, expr = arg in - let has_partial_attr = - ParsetreeViewer.has_partial_attribute expr.Parsetree.pexp_attributes - in - let doc = print_argument ~state arg cmt_tbl in - (flag || has_partial_attr, doc :: acc)) - args (false, []) + let printed_args = + List.map (fun arg -> print_argument ~state arg cmt_tbl) args in Doc.group (Doc.concat @@ -4860,7 +4893,7 @@ and print_arguments ~state ?(partial = false) Doc.soft_line; Doc.join ~sep:(Doc.concat [Doc.comma; Doc.line]) printed_args; ]); - (if partial || has_partial_attr then Doc.nil else Doc.trailing_comma); + (if partial then Doc.nil else Doc.trailing_comma); Doc.soft_line; Doc.rparen; ]) diff --git a/tests/analysis_tests/tests/src/CompletionFunctionArguments.res b/tests/analysis_tests/tests/src/CompletionFunctionArguments.res index 5000ee49c6..0e06501304 100644 --- a/tests/analysis_tests/tests/src/CompletionFunctionArguments.res +++ b/tests/analysis_tests/tests/src/CompletionFunctionArguments.res @@ -17,12 +17,12 @@ let tLocalVar = false // let _ = someFn(~isOff=) // ^com -let _ = @res.partial someFn( +let _ = someFn( ~isOn={ // switch someFn(~isOn=) // ^com true - }, + }, ... ) let someOtherFn = (includeName, age, includeAge) => { diff --git a/tests/analysis_tests/tests/src/Highlight.res b/tests/analysis_tests/tests/src/Highlight.res index 225f0c48a9..47c0a2aae0 100644 --- a/tests/analysis_tests/tests/src/Highlight.res +++ b/tests/analysis_tests/tests/src/Highlight.res @@ -69,7 +69,7 @@ let foo = x => x.T.someField let add = (~hello as x, ~world) => x + world -let _ = @res.partial add(~hello=3) +let _ = add(~hello=3, ...) let _ =
diff --git a/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt b/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt index 5d6311f483..30dd19d89a 100644 --- a/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt +++ b/tests/analysis_tests/tests/src/expected/CompletionFunctionArguments.res.txt @@ -66,8 +66,8 @@ Path someFn }] Complete src/CompletionFunctionArguments.res 21:27 -posCursor:[21:27] posNoWhite:[21:26] Found expr:[19:21->25:1] -Pexp_apply ...[19:21->19:27] (~isOn20:3->20:7=...[21:7->23:8]) +posCursor:[21:27] posNoWhite:[21:26] Found expr:[19:8->25:1] +Pexp_apply ...[19:8->19:14] (~isOn20:3->20:7=...[21:7->23:8]) posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:7->23:8] posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:7->21:28] posCursor:[21:27] posNoWhite:[21:26] Found expr:[21:14->21:28] diff --git a/tests/analysis_tests/tests/src/expected/Highlight.res.txt b/tests/analysis_tests/tests/src/expected/Highlight.res.txt index a4ab8e1422..db7155bfdd 100644 --- a/tests/analysis_tests/tests/src/expected/Highlight.res.txt +++ b/tests/analysis_tests/tests/src/expected/Highlight.res.txt @@ -81,7 +81,7 @@ Variable: x [69:21->69:22] Variable: world [69:24->69:30] Lident: x 69:35 Variable Lident: world 69:39 Variable -Lident: add 71:21 Variable +Lident: add 71:8 Variable JsxTag <: 73:8 Lident: div 73:9 JsxLowercase Lident: div 73:36 JsxLowercase