Skip to content

Commit 72846f8

Browse files
committed
Merge branch 'master' into test-docstrings-examples
2 parents f35f121 + 6f24778 commit 72846f8

File tree

206 files changed

+2601
-2886
lines changed

Some content is hidden

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

206 files changed

+2601
-2886
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# 12.0.0-alpha.6 (Unreleased)
1414
- Fix exponential notation syntax. https://github.com/rescript-lang/rescript/pull/7174
1515
- Add `Option.all` & `Result.all` helpers. https://github.com/rescript-lang/rescript/pull/7181
16+
- Add `@react.componentWithProps` that explicitly handles the props with shared props: https://github.com/rescript-lang/rescript/pull/7203
1617

1718
#### :bug: Bug fix
1819
- Fix bug where a ref assignment is moved ouside a conditional. https://github.com/rescript-lang/rescript/pull/7176
@@ -28,6 +29,10 @@
2829
- AST cleanup: Remove Pexp_function from the AST. https://github.com/rescript-lang/rescript/pull/7198
2930
- Remove unused code from Location and Rescript_cpp modules. https://github.com/rescript-lang/rescript/pull/7150
3031
- Build with OCaml 5.2.1. https://github.com/rescript-lang/rescript-compiler/pull/7201
32+
- AST cleanup: Remove `Function$` entirely for function definitions. https://github.com/rescript-lang/rescript/pull/7200
33+
- AST cleanup: store arity in function type https://github.com/rescript-lang/rescript/pull/7195
34+
- AST cleanup: remove explicit uses of `function$` in preparation for removing the type entirely. https://github.com/rescript-lang/rescript/pull/7206
35+
- AST cleanup: remove `function$` entirely. https://github.com/rescript-lang/rescript/pull/7208
3136

3237
# 12.0.0-alpha.5
3338

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,11 @@
99
</p>
1010

1111
<p align="center">
12-
<a href="https://www.npmjs.org/package/rescript">
13-
<img src="https://img.shields.io/npm/v/rescript?color=brightgreen&label=npm%20package" alt="Current npm package version." />
14-
</a>
15-
<a href="https://github.com/rescript-lang/rescript-compiler/actions">
16-
<img src="https://github.com//rescript-lang/rescript-compiler/workflows/CI/badge.svg" alt="Current Github Actions workflow status." />
17-
</a>
18-
<a href="https://github.com/rescript-lang/rescript-compiler/blob/HEAD/LICENSE">
19-
<img src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" alt="ReScript is released under the LGPL license." />
20-
</a>
21-
<a href="https://x.com/intent/follow?screen_name=rescriptlang">
22-
<img src="https://img.shields.io/badge/X-000000?style=flat&logo=x&logoColor=white" alt="Follow @rescriptlang on X" />
23-
</a>
24-
<a href="https://bsky.app/profile/rescript-lang.org">
25-
<img src="https://img.shields.io/badge/Bluesky-0285FF?logo=bluesky&logoColor=fff&style=flat" alt="Follow @rescriptlang on Bluesky" />
26-
</a>
12+
<a href="https://www.npmjs.org/package/rescript"><img src="https://img.shields.io/npm/v/rescript?color=brightgreen&label=npm%20package" alt="Current npm package version." /></a>
13+
<a href="https://github.com/rescript-lang/rescript/actions"><img src="https://github.com//rescript-lang/rescript/workflows/CI/badge.svg" alt="Current Github Actions workflow status." /></a>
14+
<a href="https://github.com/rescript-lang/rescript/blob/HEAD/LICENSE"><img src="https://img.shields.io/badge/License-LGPL%20v3-blue.svg" alt="ReScript is released under the LGPL license." /></a>
15+
<a href="https://x.com/intent/follow?screen_name=rescriptlang"><img src="https://img.shields.io/badge/X-000000?style=flat&logo=x&logoColor=white" alt="Follow @rescriptlang on X" /></a>
16+
<a href="https://bsky.app/profile/rescript-lang.org"><img src="https://img.shields.io/badge/Bluesky-0285FF?logo=bluesky&logoColor=fff&style=flat" alt="Follow @rescriptlang on Bluesky" /></a>
2717
</p>
2818

2919
<h3 align="center">

analysis/reanalyze/src/Arnold.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ module FindFunctionsCalled = struct
545545
let findCallees (expression : Typedtree.expression) =
546546
let isFunction =
547547
match expression.exp_desc with
548-
| Texp_function _ -> true
548+
| Texp_function {arity = None} -> true
549549
| _ -> false
550550
in
551551
let callees = ref StringSet.empty in

analysis/reanalyze/src/DeadOptionalArgs.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ let addFunctionReference ~(locFrom : Location.t) ~(locTo : Location.t) =
3131
let rec hasOptionalArgs (texpr : Types.type_expr) =
3232
match texpr.desc with
3333
| _ when not (active ()) -> false
34-
| Tarrow (Optional _, _tFrom, _tTo, _) -> true
35-
| Tarrow (_, _tFrom, tTo, _) -> hasOptionalArgs tTo
34+
| Tarrow (Optional _, _tFrom, _tTo, _, _) -> true
35+
| Tarrow (_, _tFrom, tTo, _, _) -> hasOptionalArgs tTo
3636
| Tlink t -> hasOptionalArgs t
3737
| Tsubst t -> hasOptionalArgs t
3838
| _ -> false
3939

4040
let rec fromTypeExpr (texpr : Types.type_expr) =
4141
match texpr.desc with
4242
| _ when not (active ()) -> []
43-
| Tarrow (Optional s, _tFrom, tTo, _) -> s :: fromTypeExpr tTo
44-
| Tarrow (_, _tFrom, tTo, _) -> fromTypeExpr tTo
43+
| Tarrow (Optional s, _tFrom, tTo, _, _) -> s :: fromTypeExpr tTo
44+
| Tarrow (_, _tFrom, tTo, _, _) -> fromTypeExpr tTo
4545
| Tlink t -> fromTypeExpr t
4646
| Tsubst t -> fromTypeExpr t
4747
| _ -> []

analysis/src/CompletionBackEnd.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
898898
| [] -> tRet
899899
| (label, tArg) :: rest ->
900900
let restType = reconstructFunctionType rest tRet in
901-
{typ with desc = Tarrow (label, tArg, restType, Cok)}
901+
{typ with desc = Tarrow (label, tArg, restType, Cok, None)}
902902
in
903903
let rec processApply args labels =
904904
match (args, labels) with
@@ -1359,11 +1359,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
13591359
(* Find all functions in the module that returns type t *)
13601360
let rec fnReturnsTypeT t =
13611361
match t.Types.desc with
1362-
| Tlink t1
1363-
| Tsubst t1
1364-
| Tpoly (t1, [])
1365-
| Tconstr (Pident {name = "function$"}, [t1; _], _) ->
1366-
fnReturnsTypeT t1
1362+
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> fnReturnsTypeT t1
13671363
| Tarrow _ -> (
13681364
match TypeUtils.extractFunctionType ~env ~package:full.package t with
13691365
| ( (Nolabel, {desc = Tconstr (Path.Pident {name = "t"}, _, _)}) :: _,

analysis/src/CompletionFrontEnd.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
10931093
(* Ignore list expressions, used in JSX, unit, and more *) ()
10941094
| Pexp_construct (lid, eOpt) -> (
10951095
let lidPath = flattenLidCheckDot lid in
1096-
if debug && lid.txt <> Lident "Function$" then
1096+
if debug then
10971097
Printf.printf "Pexp_construct %s:%s %s\n"
10981098
(lidPath |> String.concat "\n")
10991099
(Loc.toString lid.loc)

analysis/src/CompletionJsx.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,7 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package =
235235
in
236236
let rec getLabels (t : Types.type_expr) =
237237
match t.desc with
238-
| Tlink t1
239-
| Tsubst t1
240-
| Tpoly (t1, [])
241-
| Tconstr (Pident {name = "function$"}, [t1; _], _) ->
242-
getLabels t1
238+
| Tlink t1 | Tsubst t1 | Tpoly (t1, []) -> getLabels t1
243239
| Tconstr (p, [propsType], _) when Path.name p = "React.component" -> (
244240
let rec getPropsType (t : Types.type_expr) =
245241
match t.desc with
@@ -251,15 +247,15 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package =
251247
match propsType |> getPropsType with
252248
| Some (path, typeArgs) -> getFields ~path ~typeArgs
253249
| None -> [])
254-
| Tarrow (Nolabel, {desc = Tconstr (path, typeArgs, _)}, _, _)
250+
| Tarrow (Nolabel, {desc = Tconstr (path, typeArgs, _)}, _, _, _)
255251
when Path.last path = "props" ->
256252
getFields ~path ~typeArgs
257253
| Tconstr (clPath, [{desc = Tconstr (path, typeArgs, _)}; _], _)
258254
when Path.name clPath = "React.componentLike"
259255
&& Path.last path = "props" ->
260256
(* JSX V4 external or interface *)
261257
getFields ~path ~typeArgs
262-
| Tarrow (Nolabel, typ, _, _) -> (
258+
| Tarrow (Nolabel, typ, _, _, _) -> (
263259
(* Component without the JSX PPX, like a make fn taking a hand-written
264260
type props. *)
265261
let rec digToConstr typ =

analysis/src/CreateInterface.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ let printSignature ~extractor ~signature =
118118

119119
let buf = Buffer.create 10 in
120120

121-
let rec getComponentType (typ : Types.type_expr) =
121+
let getComponentType (typ : Types.type_expr) =
122122
let reactElement =
123123
Ctype.newconstr (Pdot (Pident (Ident.create "React"), "element", 0)) []
124124
in
125125
match typ.desc with
126-
| Tconstr (Pident {name = "function$"}, [typ; _], _) -> getComponentType typ
127-
| Tarrow (_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _)
126+
| Tarrow
127+
(_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _, _)
128128
when Ident.name propsId = "props" ->
129129
Some (typeArgs, retType)
130130
| Tconstr
@@ -173,14 +173,17 @@ let printSignature ~extractor ~signature =
173173
if labelDecl.ld_optional then Asttypes.Optional lblName
174174
else Labelled lblName
175175
in
176-
{retType with desc = Tarrow (lbl, propType, mkFunType rest, Cok)}
176+
{
177+
retType with
178+
desc = Tarrow (lbl, propType, mkFunType rest, Cok, None);
179+
}
177180
in
178181
let funType =
179182
if List.length labelDecls = 0 (* No props *) then
180183
let tUnit =
181184
Ctype.newconstr (Path.Pident (Ident.create "unit")) []
182185
in
183-
{retType with desc = Tarrow (Nolabel, tUnit, retType, Cok)}
186+
{retType with desc = Tarrow (Nolabel, tUnit, retType, Cok, None)}
184187
else mkFunType labelDecls
185188
in
186189
sigItemToString

analysis/src/Hint.ml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ let inlay ~path ~pos ~maxLength ~debug =
6060
( Pexp_constant _ | Pexp_tuple _ | Pexp_record _ | Pexp_variant _
6161
| Pexp_apply _ | Pexp_match _ | Pexp_construct _ | Pexp_ifthenelse _
6262
| Pexp_array _ | Pexp_ident _ | Pexp_try _ | Pexp_lazy _
63-
| Pexp_send _ | Pexp_field _ | Pexp_open _ );
63+
| Pexp_send _ | Pexp_field _ | Pexp_open _
64+
| Pexp_fun (_, _, _, _, Some _) );
6465
};
6566
} ->
6667
push vb.pvb_pat.ppat_loc Type
@@ -125,12 +126,7 @@ let codeLens ~path ~debug =
125126
(match vb with
126127
| {
127128
pvb_pat = {ppat_desc = Ppat_var _; ppat_loc};
128-
pvb_expr =
129-
{
130-
pexp_desc =
131-
Pexp_construct
132-
({txt = Lident "Function$"}, Some {pexp_desc = Pexp_fun _});
133-
};
129+
pvb_expr = {pexp_desc = Pexp_fun _};
134130
} ->
135131
push ppat_loc
136132
| _ -> ());

analysis/src/Shared.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ let findTypeConstructors (tel : Types.type_expr list) =
5252
| Tconstr (path, args, _) ->
5353
addPath path;
5454
args |> List.iter loop
55-
| Tarrow (_, te1, te2, _) ->
55+
| Tarrow (_, te1, te2, _, _) ->
5656
loop te1;
5757
loop te2
5858
| Ttuple tel -> tel |> List.iter loop

0 commit comments

Comments
 (0)