Skip to content

Commit 32a149c

Browse files
committed
Merge branch 'master' into result-get-or-throw-message
2 parents 4db417c + 736159e commit 32a149c

File tree

186 files changed

+2773
-2984
lines changed

Some content is hidden

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

186 files changed

+2773
-2984
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ jobs:
476476
run: .github/workflows/moveArtifacts.sh
477477
shell: bash
478478

479+
- name: Check artifact list
480+
run: node ./scripts/npmPack.js
481+
479482
- name: Publish packages to pkg.pr.new
480483
run: |
481484
yarn dlx pkg-pr-new publish "." "./packages/@rescript/*"

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,30 @@
1212
1313
# 12.0.0-beta.2 (Unreleased)
1414

15-
#### :rocket: New Feature
15+
#### :nail_care: Polish
1616

17-
- Add optional `message` argument to `Result.getOrThrow` and improve default error message. https://github.com/rescript-lang/rescript/pull/7630
17+
- Add missing backtick and spaces to `Belt.Map.map` doc comment. https://github.com/rescript-lang/rescript/pull/7632
1818

1919
#### :house: Internal
2020

2121
- Remove internal/unused `-bs-v` flag. https://github.com/rescript-lang/rescript/pull/7627
22+
- Remove unused `-bs-D` and `-bs-list-conditionals` flags. https://github.com/rescript-lang/rescript/pull/7631
23+
- Remove obsolete jsx options. https://github.com/rescript-lang/rescript/pull/7633
24+
- Remove obsolete option `-bs-unsafe-empty-array`. https://github.com/rescript-lang/rescript/pull/7635
25+
- Clean up `config.ml`. https://github.com/rescript-lang/rescript/pull/7636
26+
- Rewatch: simplify getting bsc path. https://github.com/rescript-lang/rescript/pull/7634
27+
- Rewatch: only get `"type": "dev"` source files for local packages. https://github.com/rescript-lang/rescript/pull/7646
28+
29+
#### :rocket: New Feature
30+
31+
- Add experimental command to `rescript-tools` for extracting all ReScript code blocks from markdown, either a md-file directly, or inside of docstrings in ReScript code. https://github.com/rescript-lang/rescript/pull/7623
32+
- Add optional `message` argument to `Result.getOrThrow` and improve default error message. https://github.com/rescript-lang/rescript/pull/7630
33+
34+
#### :bug: Bug fix
35+
36+
- Fix `typeof` parens on functions. https://github.com/rescript-lang/rescript/pull/7643
37+
- Rewatch: Add --dev flag to clean command. https://github.com/rescript-lang/rescript/pull/7622
38+
- Rewatch: Use root package suffix in clean log messages. https://github.com/rescript-lang/rescript/pull/7648
2239

2340
# 12.0.0-beta.1
2441

analysis/examples/example-project/bsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"number": "-32-26-27-33"
77
},
88
"bs-dependencies": ["reason-react"],
9-
"reason": { "react-jsx": 3 },
109
"namespace": "my-namespace",
1110
"reanalyze": {
1211
"analysis": ["dce", "exception"]

analysis/examples/larger-project/bsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
},
77
"name": "sample-typescript-app",
88
"bsc-flags": ["-bs-super-errors -w a"],
9-
"reason": { "react-jsx": 3 },
109
"bs-dependencies": ["@rescript/react", "@glennsl/bs-json"],
1110
"sources": [
1211
{

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 ({lbl = Optional _}, _tTo, _, _) -> true
35+
| Tarrow (_, 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 ({lbl = Optional s}, tTo, _, _) -> s :: fromTypeExpr tTo
44+
| Tarrow (_, tTo, _, _) -> fromTypeExpr tTo
4545
| Tlink t -> fromTypeExpr t
4646
| Tsubst t -> fromTypeExpr t
4747
| _ -> []

analysis/src/CompletionBackEnd.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,10 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
978978
| [] -> tRet
979979
| (label, tArg) :: rest ->
980980
let restType = reconstructFunctionType rest tRet in
981-
{typ with desc = Tarrow (label, tArg, restType, Cok, None)}
981+
{
982+
typ with
983+
desc = Tarrow ({lbl = label; typ = tArg}, restType, Cok, None);
984+
}
982985
in
983986
let rec processApply args labels =
984987
match (args, labels) with

analysis/src/CompletionJsx.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,16 @@ let getJsxLabels ~componentPath ~findTypeOfValue ~package =
247247
match propsType |> getPropsType with
248248
| Some (path, typeArgs) -> getFields ~path ~typeArgs
249249
| None -> [])
250-
| Tarrow (Nolabel, {desc = Tconstr (path, typeArgs, _)}, _, _, _)
250+
| Tarrow
251+
({lbl = Nolabel; typ = {desc = Tconstr (path, typeArgs, _)}}, _, _, _)
251252
when Path.last path = "props" ->
252253
getFields ~path ~typeArgs
253254
| Tconstr (clPath, [{desc = Tconstr (path, typeArgs, _)}; _], _)
254255
when Path.name clPath = "React.componentLike"
255256
&& Path.last path = "props" ->
256257
(* JSX V4 external or interface *)
257258
getFields ~path ~typeArgs
258-
| Tarrow (Nolabel, typ, _, _, _) -> (
259+
| Tarrow ({lbl = Nolabel; typ}, _, _, _) -> (
259260
(* Component without the JSX PPX, like a make fn taking a hand-written
260261
type props. *)
261262
let rec digToConstr typ =

analysis/src/CreateInterface.ml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ let printSignature ~extractor ~signature =
124124
in
125125
match typ.desc with
126126
| Tarrow
127-
(_, {desc = Tconstr (Path.Pident propsId, typeArgs, _)}, retType, _, _)
127+
( {typ = {desc = Tconstr (Path.Pident propsId, typeArgs, _)}},
128+
retType,
129+
_,
130+
_ )
128131
when Ident.name propsId = "props" ->
129132
Some (typeArgs, retType)
130133
| Tconstr
@@ -175,15 +178,18 @@ let printSignature ~extractor ~signature =
175178
in
176179
{
177180
retType with
178-
desc = Tarrow (lbl, propType, mkFunType rest, Cok, None);
181+
desc = Tarrow ({lbl; typ = propType}, mkFunType rest, Cok, None);
179182
}
180183
in
181184
let funType =
182185
if List.length labelDecls = 0 (* No props *) then
183186
let tUnit =
184187
Ctype.newconstr (Path.Pident (Ident.create "unit")) []
185188
in
186-
{retType with desc = Tarrow (Nolabel, tUnit, retType, Cok, None)}
189+
{
190+
retType with
191+
desc = Tarrow ({lbl = Nolabel; typ = tUnit}, retType, Cok, None);
192+
}
187193
else mkFunType labelDecls
188194
in
189195
sigItemToString

analysis/src/Protocol.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ let optWrapInQuotes s =
137137
| None -> None
138138
| Some s -> Some (wrapInQuotes s)
139139

140+
let stringifyResult = function
141+
| Ok r -> stringifyObject [("TAG", Some (wrapInQuotes "Ok")); ("_0", Some r)]
142+
| Error e ->
143+
stringifyObject [("TAG", Some (wrapInQuotes "Error")); ("_0", Some e)]
144+
140145
let stringifyCompletionItem c =
141146
stringifyObject
142147
[

analysis/src/Shared.ml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ let tryReadCmt cmt =
55
else
66
match Cmt_format.read_cmt cmt with
77
| exception Cmi_format.Error err ->
8-
Log.log
9-
("Failed to load " ^ cmt ^ " as a cmt w/ ocaml version " ^ "406"
10-
^ ", error: "
11-
^
12-
(Cmi_format.report_error Format.str_formatter err;
13-
Format.flush_str_formatter ()));
8+
let error_message =
9+
Cmi_format.report_error Format.str_formatter err;
10+
Format.flush_str_formatter ()
11+
in
12+
Log.log ("Invalid cmt format " ^ cmt ^ ": " ^ error_message);
1413
None
1514
| exception err ->
16-
Log.log
17-
("Invalid cmt format " ^ cmt
18-
^ " - probably wrong ocaml version, expected " ^ Config.version ^ " : "
19-
^ Printexc.to_string err);
15+
Log.log ("Invalid cmt format " ^ cmt ^ ": " ^ Printexc.to_string err);
2016
None
2117
| x -> Some x
2218

@@ -52,9 +48,9 @@ let findTypeConstructors (tel : Types.type_expr list) =
5248
| Tconstr (path, args, _) ->
5349
addPath path;
5450
args |> List.iter loop
55-
| Tarrow (_, te1, te2, _, _) ->
56-
loop te1;
57-
loop te2
51+
| Tarrow (arg, ret, _, _) ->
52+
loop arg.typ;
53+
loop ret
5854
| Ttuple tel -> tel |> List.iter loop
5955
| Tnil | Tvar _ | Tobject _ | Tfield _ | Tvariant _ | Tunivar _ | Tpackage _
6056
->

0 commit comments

Comments
 (0)