Skip to content

Commit 6f615bf

Browse files
committed
Put type without locs inside module Noloc.
1 parent 783670a commit 6f615bf

Some content is hidden

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

45 files changed

+151
-153
lines changed

analysis/reanalyze/src/Arnold.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ module ExtendFunctionTable = struct
582582
Texp_apply {funct = {exp_desc = Texp_ident (path, {loc}, _)}; args};
583583
}
584584
when kindOpt <> None ->
585-
let checkArg ((argLabel : Asttypes.arg_label), _argOpt) =
585+
let checkArg ((argLabel : Asttypes.Noloc.arg_label), _argOpt) =
586586
match (argLabel, kindOpt) with
587587
| (Labelled l | Optional l), Some kind ->
588588
kind |> List.for_all (fun {Kind.label} -> label <> l)
@@ -624,7 +624,7 @@ module ExtendFunctionTable = struct
624624
when callee |> FunctionTable.isInFunctionInTable ~functionTable ->
625625
let functionName = Path.name callee in
626626
args
627-
|> List.iter (fun ((argLabel : Asttypes.arg_label), argOpt) ->
627+
|> List.iter (fun ((argLabel : Asttypes.Noloc.arg_label), argOpt) ->
628628
match (argLabel, argOpt |> extractLabelledArgument) with
629629
| Labelled label, Some (path, loc)
630630
when path |> FunctionTable.isInFunctionInTable ~functionTable
@@ -672,7 +672,7 @@ module CheckExpressionWellFormed = struct
672672
->
673673
let functionName = Path.name functionPath in
674674
args
675-
|> List.iter (fun ((argLabel : Asttypes.arg_label), argOpt) ->
675+
|> List.iter (fun ((argLabel : Asttypes.Noloc.arg_label), argOpt) ->
676676
match argOpt |> ExtendFunctionTable.extractLabelledArgument with
677677
| Some (path, loc) -> (
678678
match argLabel with
@@ -761,7 +761,7 @@ module Compile = struct
761761
let argsFromKind =
762762
innerFunctionDefinition.kind
763763
|> List.map (fun (entry : Kind.entry) ->
764-
( Asttypes.Labelled entry.label,
764+
( Asttypes.Noloc.Labelled entry.label,
765765
Some
766766
{
767767
expr with
@@ -785,7 +785,7 @@ module Compile = struct
785785
args
786786
|> List.find_opt (fun arg ->
787787
match arg with
788-
| Asttypes.Labelled s, Some _ -> s = label
788+
| Asttypes.Noloc.Labelled s, Some _ -> s = label
789789
| _ -> false)
790790
in
791791
let argOpt =

analysis/reanalyze/src/DeadValue.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ let processOptionalArgs ~expType ~(locFrom : Location.t) ~locTo ~path args =
104104
| None -> Some false
105105
in
106106
match lbl with
107-
| Asttypes.Optional s when not locFrom.loc_ghost ->
107+
| Asttypes.Noloc.Optional s when not locFrom.loc_ghost ->
108108
if argIsSupplied <> Some false then supplied := s :: !supplied;
109109
if argIsSupplied = None then suppliedMaybe := s :: !suppliedMaybe
110110
| _ -> ());

analysis/src/CompletionBackEnd.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,8 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
952952
(* compute the application of the first label, then the next ones *)
953953
let args = processApply args [label] in
954954
processApply args nextLabels
955-
| (Asttypes.Nolabel, _) :: nextArgs, [Asttypes.Nolabel] -> nextArgs
955+
| (Asttypes.Noloc.Nolabel, _) :: nextArgs, [Asttypes.Noloc.Nolabel] ->
956+
nextArgs
956957
| ((Labelled _, _) as arg) :: nextArgs, [Nolabel] ->
957958
arg :: processApply nextArgs labels
958959
| (Optional _, _) :: nextArgs, [Nolabel] -> processApply nextArgs labels
@@ -1007,9 +1008,9 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10071008
synthetic = true;
10081009
contextPath =
10091010
(match cp with
1010-
| CPApply (c, args) -> CPApply (c, args @ [Asttypes.Nolabel])
1011+
| CPApply (c, args) -> CPApply (c, args @ [Asttypes.Noloc.Nolabel])
10111012
| CPId _ when TypeUtils.isFunctionType ~env ~package typ ->
1012-
CPApply (cp, [Asttypes.Nolabel])
1013+
CPApply (cp, [Asttypes.Noloc.Nolabel])
10131014
| _ -> cp);
10141015
id = fieldName;
10151016
inJsx = false;

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
299299
| None -> None
300300
| Some contexPath ->
301301
Some
302-
(CPApply
303-
(contexPath, args |> List.map fst |> List.map Asttypes.to_arg_label))
302+
(CPApply (contexPath, args |> List.map fst |> List.map Asttypes.to_noloc))
304303
)
305304
| Pexp_tuple exprs ->
306305
let exprsAsContextPaths = exprs |> List.filter_map exprToContextPath in

analysis/src/CreateInterface.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ let printSignature ~extractor ~signature =
170170
in
171171
let lblName = labelDecl.ld_id |> Ident.name in
172172
let lbl =
173-
if labelDecl.ld_optional then Asttypes.Optional lblName
173+
if labelDecl.ld_optional then Asttypes.Noloc.Optional lblName
174174
else Labelled lblName
175175
in
176176
{

analysis/src/SharedTypes.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let ident l = l |> List.map str |> String.concat "."
44

55
type path = string list
66

7-
type typedFnArg = Asttypes.arg_label * Types.type_expr
7+
type typedFnArg = Asttypes.Noloc.arg_label * Types.type_expr
88

99
let pathToString (path : path) = path |> String.concat "."
1010

@@ -605,7 +605,7 @@ module Completable = struct
605605
| CPFloat
606606
| CPBool
607607
| CPOption of contextPath
608-
| CPApply of contextPath * Asttypes.arg_label list
608+
| CPApply of contextPath * Asttypes.Noloc.arg_label list
609609
| CPId of {
610610
path: string list;
611611
completionContext: completionContext;
@@ -692,7 +692,7 @@ module Completable = struct
692692
contextPathToString cp ^ "("
693693
^ (labels
694694
|> List.map (function
695-
| Asttypes.Nolabel -> "Nolabel"
695+
| Asttypes.Noloc.Nolabel -> "Nolabel"
696696
| Labelled s -> "~" ^ s
697697
| Optional s -> "?" ^ s)
698698
|> String.concat ", ")

analysis/src/SignatureHelp.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ let findActiveParameter ~argAtCursor ~args =
154154
(* If a function only has one, unlabelled argument, we can safely assume that's active whenever we're in the signature help for that function,
155155
even if we technically didn't find anything at the cursor (which we don't for empty expressions). *)
156156
match args with
157-
| [(Asttypes.Nolabel, _)] -> Some 0
157+
| [(Asttypes.Noloc.Nolabel, _)] -> Some 0
158158
| _ -> None)
159159
| Some (Unlabelled unlabelledArgumentIndex) ->
160160
let index = ref 0 in
161161
args
162162
|> List.find_map (fun (label, _) ->
163163
match label with
164-
| Asttypes.Nolabel when !index = unlabelledArgumentIndex ->
164+
| Asttypes.Noloc.Nolabel when !index = unlabelledArgumentIndex ->
165165
Some !index
166166
| _ ->
167167
index := !index + 1;
@@ -171,7 +171,7 @@ let findActiveParameter ~argAtCursor ~args =
171171
args
172172
|> List.find_map (fun (label, _) ->
173173
match label with
174-
| (Asttypes.Labelled labelName | Optional labelName)
174+
| (Asttypes.Noloc.Labelled labelName | Optional labelName)
175175
when labelName = name ->
176176
Some !index
177177
| _ ->
@@ -474,7 +474,7 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
474474
parameters =
475475
parameters
476476
|> List.map (fun (argLabel, start, end_) ->
477-
let argLabel = Asttypes.to_arg_label argLabel in
477+
let argLabel = Asttypes.to_noloc argLabel in
478478
let paramArgCount = !paramUnlabelledArgCount in
479479
paramUnlabelledArgCount := paramArgCount + 1;
480480
let unlabelledArgCount = ref 0 in
@@ -487,8 +487,8 @@ let signatureHelp ~path ~pos ~currentFile ~debug ~allowForConstructorPayloads =
487487
let argCount = !unlabelledArgCount in
488488
unlabelledArgCount := argCount + 1;
489489
match (lbl, argLabel) with
490-
| ( Asttypes.Optional l1,
491-
Asttypes.Optional l2 )
490+
| ( Asttypes.Noloc.Optional l1,
491+
Asttypes.Noloc.Optional l2 )
492492
when l1 = l2 ->
493493
true
494494
| Labelled l1, Labelled l2

analysis/src/TypeUtils.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ let getFirstFnUnlabelledArgType ~env ~full t =
11231123
in
11241124
let rec findFirstUnlabelledArgType labels =
11251125
match labels with
1126-
| (Asttypes.Nolabel, t) :: _ -> Some t
1126+
| (Asttypes.Noloc.Nolabel, t) :: _ -> Some t
11271127
| _ :: rest -> findFirstUnlabelledArgType rest
11281128
| [] -> None
11291129
in

compiler/frontend/ast_compatible.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ type object_field = Parsetree.object_field
160160

161161
let object_field l attrs ty = Parsetree.Otag (l, attrs, ty)
162162

163-
type args = (Asttypes.arg_label_loc * Parsetree.expression) list
163+
type args = (Asttypes.arg_label * Parsetree.expression) list

compiler/frontend/ast_compatible.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,4 @@ type object_field = Parsetree.object_field
137137
val object_field :
138138
Asttypes.label Asttypes.loc -> attributes -> core_type -> object_field
139139

140-
type args = (Asttypes.arg_label_loc * Parsetree.expression) list
140+
type args = (Asttypes.arg_label * Parsetree.expression) list

compiler/frontend/ast_core_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ let get_curry_arity (ty : t) =
131131
let is_arity_one ty = get_curry_arity ty = 1
132132

133133
type param_type = {
134-
label: Asttypes.arg_label_loc;
134+
label: Asttypes.arg_label;
135135
ty: Parsetree.core_type;
136136
attr: Parsetree.attributes;
137137
loc: loc;

compiler/frontend/ast_core_type.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ val get_uncurry_arity : t -> int option
4848
*)
4949

5050
type param_type = {
51-
label: Asttypes.arg_label_loc;
51+
label: Asttypes.arg_label;
5252
ty: t;
5353
attr: Parsetree.attributes;
5454
loc: Location.t;

compiler/frontend/ast_pat.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ val arity_of_fun : t -> Parsetree.expression -> int
3030
(** [arity_of_fun pat e] tells the arity of
3131
expression [fun pat -> e]*)
3232

33-
val labels_of_fun : Parsetree.expression -> Asttypes.arg_label_loc list
33+
val labels_of_fun : Parsetree.expression -> Asttypes.arg_label list
3434

3535
val is_single_variable_pattern_conservative : t -> string option

compiler/frontend/ast_typ_uncurry.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
type typ = Parsetree.core_type
2626
type 'a cxt = Ast_helper.loc -> Bs_ast_mapper.mapper -> 'a
27-
type uncurry_type_gen = (Asttypes.arg_label_loc -> typ -> typ -> typ) cxt
27+
type uncurry_type_gen = (Asttypes.arg_label -> typ -> typ -> typ) cxt
2828

2929
module Typ = Ast_helper.Typ
3030

3131
let to_method_callback_type loc (mapper : Bs_ast_mapper.mapper)
32-
(label : Asttypes.arg_label_loc) (first_arg : Parsetree.core_type)
32+
(label : Asttypes.arg_label) (first_arg : Parsetree.core_type)
3333
(typ : Parsetree.core_type) =
3434
let first_arg = mapper.typ mapper first_arg in
3535
let typ = mapper.typ mapper typ in
@@ -46,7 +46,7 @@ let to_method_callback_type loc (mapper : Bs_ast_mapper.mapper)
4646
| None -> assert false
4747

4848
let to_uncurry_type loc (mapper : Bs_ast_mapper.mapper)
49-
(label : Asttypes.arg_label_loc) (first_arg : Parsetree.core_type)
49+
(label : Asttypes.arg_label) (first_arg : Parsetree.core_type)
5050
(typ : Parsetree.core_type) =
5151
(* no need to error for optional here,
5252
since we can not make it

compiler/frontend/ast_typ_uncurry.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type typ = Parsetree.core_type
4040
type 'a cxt = Ast_helper.loc -> Bs_ast_mapper.mapper -> 'a
4141

4242
type uncurry_type_gen =
43-
(Asttypes.arg_label_loc ->
43+
(Asttypes.arg_label ->
4444
(* label for error checking *)
4545
typ ->
4646
(* First arg *)

compiler/frontend/ast_uncurry_gen.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
val to_method_callback :
2626
Location.t ->
2727
Bs_ast_mapper.mapper ->
28-
Asttypes.arg_label_loc ->
28+
Asttypes.arg_label ->
2929
Parsetree.pattern ->
3030
Parsetree.expression ->
3131
Parsetree.expression_desc

compiler/frontend/bs_syntaxerr.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ let () =
104104

105105
let err loc error = raise (Error (loc, error))
106106

107-
let optional_err loc (lbl : Asttypes.arg_label_loc) =
107+
let optional_err loc (lbl : Asttypes.arg_label) =
108108
match lbl with
109109
| Opt _ -> raise (Error (loc, Optional_in_uncurried_bs_attribute))
110110
| _ -> ()
111111

112-
let err_if_label loc (lbl : Asttypes.arg_label_loc) =
112+
let err_if_label loc (lbl : Asttypes.arg_label) =
113113
if lbl <> Nolbl then raise (Error (loc, Misplaced_label_syntax))

compiler/frontend/bs_syntaxerr.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ type error =
5454

5555
val err : Location.t -> error -> 'a
5656

57-
val optional_err : Location.t -> Asttypes.arg_label_loc -> unit
57+
val optional_err : Location.t -> Asttypes.arg_label -> unit
5858

59-
val err_if_label : Location.t -> Asttypes.arg_label_loc -> unit
59+
val err_if_label : Location.t -> Asttypes.arg_label -> unit

compiler/gentype/TranslateCoreType.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
open GenTypeCommon
22
open! TranslateTypeExprFromTypes
33

4-
let remove_option ~(label : Asttypes.arg_label)
4+
let remove_option ~(label : Asttypes.Noloc.arg_label)
55
(core_type : Typedtree.core_type) =
66
match (core_type.ctyp_desc, label) with
77
| Ttyp_constr (Path.Pident id, _, [t]), Optional lbl

compiler/gentype/TranslateTypeExprFromTypes.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ open GenTypeCommon
22

33
type translation = {dependencies: dep list; type_: type_}
44

5-
let rec remove_option ~(label : Asttypes.arg_label)
5+
let rec remove_option ~(label : Asttypes.Noloc.arg_label)
66
(type_expr : Types.type_expr) =
77
match (type_expr.desc, label) with
88
| Tconstr (Path.Pident id, [t], _), Optional lbl when Ident.name id = "option"

compiler/ml/ast_helper.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module Typ : sig
5858
?loc:loc ->
5959
?attrs:attrs ->
6060
arity:arity ->
61-
arg_label_loc ->
61+
arg_label ->
6262
core_type ->
6363
core_type ->
6464
core_type
@@ -140,7 +140,7 @@ module Exp : sig
140140
?attrs:attrs ->
141141
?async:bool ->
142142
arity:int option ->
143-
arg_label_loc ->
143+
arg_label ->
144144
expression option ->
145145
pattern ->
146146
expression ->
@@ -150,7 +150,7 @@ module Exp : sig
150150
?attrs:attrs ->
151151
?partial:bool ->
152152
expression ->
153-
(arg_label_loc * expression) list ->
153+
(arg_label * expression) list ->
154154
expression
155155
val match_ : ?loc:loc -> ?attrs:attrs -> expression -> case list -> expression
156156
val try_ : ?loc:loc -> ?attrs:attrs -> expression -> case list -> expression

compiler/ml/ast_mapper_from0.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module T = struct
9999
| Ptyp_any -> any ~loc ~attrs ()
100100
| Ptyp_var s -> var ~loc ~attrs s
101101
| Ptyp_arrow (lab, t1, t2) ->
102-
let lab = Asttypes.to_arg_label_loc lab in
102+
let lab = Asttypes.to_arg_label lab in
103103
arrow ~loc ~attrs ~arity:None lab (sub.typ sub t1) (sub.typ sub t2)
104104
| Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl)
105105
| Ptyp_constr (lid, tl) -> (
@@ -305,7 +305,7 @@ module E = struct
305305
| Pexp_let (r, vbs, e) ->
306306
let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) (sub.expr sub e)
307307
| Pexp_fun (lab, def, p, e) ->
308-
let lab = Asttypes.to_arg_label_loc lab in
308+
let lab = Asttypes.to_arg_label lab in
309309
let async = Ext_list.exists attrs (fun ({txt}, _) -> txt = "res.async") in
310310
fun_ ~loc ~attrs ~async ~arity:None lab
311311
(map_opt (sub.expr sub) def)
@@ -352,7 +352,7 @@ module E = struct
352352
let partial, attrs = process_partial_app_attribute attrs in
353353
apply ~loc ~attrs ~partial (sub.expr sub e)
354354
(List.map
355-
(fun (lbl, e) -> (Asttypes.to_arg_label_loc lbl, sub.expr sub e))
355+
(fun (lbl, e) -> (Asttypes.to_arg_label lbl, sub.expr sub e))
356356
l)
357357
| Pexp_match (e, pel) ->
358358
match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel)

compiler/ml/ast_mapper_to0.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module T = struct
9999
| Ptyp_any -> any ~loc ~attrs ()
100100
| Ptyp_var s -> var ~loc ~attrs s
101101
| Ptyp_arrow {lbl; arg; ret; arity} -> (
102-
let lbl = Asttypes.to_arg_label lbl in
102+
let lbl = Asttypes.to_noloc lbl in
103103
let typ0 = arrow ~loc ~attrs lbl (sub.typ sub arg) (sub.typ sub ret) in
104104
match arity with
105105
| None -> typ0
@@ -294,7 +294,7 @@ module E = struct
294294
let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) (sub.expr sub e)
295295
| Pexp_fun {arg_label = lab; default = def; lhs = p; rhs = e; arity; async}
296296
-> (
297-
let lab = Asttypes.to_arg_label lab in
297+
let lab = Asttypes.to_noloc lab in
298298
let attrs =
299299
if async then
300300
({txt = "res.async"; loc = Location.none}, Pt.PStr []) :: attrs
@@ -352,7 +352,7 @@ module E = struct
352352
in
353353
apply ~loc ~attrs (sub.expr sub e)
354354
(List.map
355-
(fun (lbl, e) -> (Asttypes.to_arg_label lbl, sub.expr sub e))
355+
(fun (lbl, e) -> (Asttypes.to_noloc lbl, sub.expr sub e))
356356
args)
357357
| Pexp_match (e, pel) ->
358358
match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel)

0 commit comments

Comments
 (0)