Skip to content

Commit 01a5b5b

Browse files
committed
Merge branch 'master' into application-completion
2 parents 8f79cd2 + fd1e7b8 commit 01a5b5b

File tree

398 files changed

+4834
-3510
lines changed

Some content is hidden

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

398 files changed

+4834
-3510
lines changed

.devcontainer/postCreate.sh

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

33
# Install dev dependencies from OPAM
44
opam init -y --bare --disable-sandboxing
5-
opam switch create 5.2.1 --packages ocaml-option-static
5+
opam switch create 5.3.0 --packages ocaml-option-static
66
opam install . --deps-only -y
77

88
# For IDE support, install the OCaml language server

.github/workflows/ci.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,32 +87,34 @@ jobs:
8787
matrix:
8888
include:
8989
- os: ubuntu-24.04 # x64
90-
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
90+
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9191
upload_binaries: true
9292
upload_libs: true
9393
- os: ubuntu-24.04-arm # ARM
94-
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
94+
ocaml_compiler: ocaml-variants.5.3.0+options,ocaml-option-static
9595
upload_binaries: true
9696
# Build the playground compiler and run the benchmarks on the fastest runner
9797
build_playground: true
9898
benchmarks: true
9999
- os: macos-13 # x64
100-
ocaml_compiler: 5.2.1
100+
ocaml_compiler: 5.3.0
101101
upload_binaries: true
102102
- os: macos-14 # ARM
103-
ocaml_compiler: 5.2.1
103+
ocaml_compiler: 5.3.0
104104
upload_binaries: true
105105
- os: windows-latest
106-
ocaml_compiler: 5.2.1
106+
ocaml_compiler: 5.3.0
107107
upload_binaries: true
108108

109109
# Verify that the compiler still builds with older OCaml versions
110+
- os: ubuntu-24.04
111+
ocaml_compiler: ocaml-variants.5.2.1+options,ocaml-option-static
112+
# Reanalyze does not work on OCaml 5.3.0 anymore, therefore run it on 5.2.1
113+
run_reanalyze: true
110114
- os: ubuntu-24.04
111115
ocaml_compiler: ocaml-variants.5.0.0+options,ocaml-option-static
112116
- os: ubuntu-24.04
113117
ocaml_compiler: ocaml-variants.4.14.2+options,ocaml-option-static
114-
- os: ubuntu-24.04
115-
ocaml_compiler: ocaml-variants.4.13.0+options,ocaml-option-static
116118

117119
runs-on: ${{matrix.os}}
118120

@@ -151,7 +153,7 @@ jobs:
151153
# matrix.ocaml_compiler may contain commas
152154
- name: Get OPAM cache key
153155
shell: bash
154-
run: echo "opam_cache_key=opam-env-v6-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
156+
run: echo "opam_cache_key=opam-env-v7-${{ matrix.os }}-${{ matrix.ocaml_compiler }}-${{ hashFiles('dune-project') }}" | sed 's/,/-/g' >> $GITHUB_ENV
155157

156158
- name: Restore OPAM environment
157159
id: cache-opam-env
@@ -189,6 +191,10 @@ jobs:
189191
if: steps.cache-opam-env.outputs.cache-hit != 'true'
190192
run: opam install . --deps-only --with-test
191193

194+
- name: "Install reanalyze"
195+
if: steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.run_reanalyze
196+
run: opam install reanalyze
197+
192198
- name: Cache OPAM environment
193199
if: steps.cache-opam-env.outputs.cache-hit != 'true'
194200
uses: actions/cache/save@v4
@@ -299,6 +305,10 @@ jobs:
299305
if: ${{ runner.os == 'Windows' }}
300306
run: opam exec -- make test-syntax
301307

308+
- name: "Syntax: Run reanalyze"
309+
if: matrix.run_reanalyze
310+
run: opam exec -- make reanalyze
311+
302312
- name: Build runtime/stdlib
303313
run: ./scripts/buildRuntime.sh
304314
shell: bash
@@ -316,7 +326,7 @@ jobs:
316326
run: git diff --ignore-cr-at-eol --exit-code tests
317327

318328
- name: Run analysis / tools tests
319-
if: runner.os != 'Windows' && matrix.os != 'ubuntu-24.04-arm'
329+
if: runner.os != 'Windows' && runner.os != 'Linux'
320330
run: opam exec -- make -C tests/analysis_tests test && make -C tests/tools_tests test
321331

322332
- name: Run gentype tests

.ocamlformat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
profile = default
2-
version = 0.26.2
2+
version = 0.27.0
33

44
field-space = tight-decl
55
break-cases = toplevel
@@ -9,3 +9,4 @@ space-around-arrays = false
99
space-around-lists = false
1010
space-around-records = false
1111
space-around-variants = false
12+
parse-docstrings = false

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,16 @@
1212
1313
# 12.0.0-alpha.9 (Unreleased)
1414

15+
#### :boom: Breaking Change
16+
17+
- Clean list API. https://github.com/rescript-lang/rescript/pull/7290
18+
1519
#### :nail_care: Polish
1620

1721
- Allow single newline in JSX. https://github.com/rescript-lang/rescript/pull/7269
22+
- Editor: Always complete from Core first. Use actual native regex syntax in code snippets for regexps. https://github.com/rescript-lang/rescript/pull/7295
23+
- Add `type t` to Stdlib modules. https://github.com/rescript-lang/rescript/pull/7302
24+
- Gentype: handle null/nullable/undefined from Stdlib. https://github.com/rescript-lang/rescript/pull/7132
1825

1926
#### :bug: Bug fix
2027

@@ -24,11 +31,17 @@
2431
- Fix completion for application with tagged template. https://github.com/rescript-lang/rescript/pull/7278
2532
- Fix error message for arity in the presence of optional arguments. https://github.com/rescript-lang/rescript/pull/7284
2633
- Fix issue in functors with more than one argument (which are curried): emit nested function always. https://github.com/rescript-lang/rescript/pull/7273
27-
- Fix dot completion issue with React primitives. https://github.com/rescript-lang/rescript/pull/7292
34+
- Fix dot completion issue with React primitives. https://github.com/rescript-lang/rescript/pull/7292
35+
- Stdlib namespace for Core modules (fixes name clashes with user modules). https://github.com/rescript-lang/rescript/pull/7285
36+
- Fix runtime type check for Object in untagged variants when one variant case is `null`. https://github.com/rescript-lang/rescript/pull/7303
37+
- Fix files that were being truncated when sent to the CDN over FTP. https://github.com/rescript-lang/rescript/pull/7306
2838

2939
#### :house: Internal
3040

3141
- Remove ignore in res_scanner.ml . https://github.com/rescript-lang/rescript/pull/7280
42+
- Use the new stdlib modules in the analysis tests. https://github.com/rescript-lang/rescript/pull/7295
43+
- Build with OCaml 5.3.0. https://github.com/rescript-lang/rescript/pull/7294
44+
- Simplify JSON.Decode implementation. https://github.com/rescript-lang/rescript/pull/7304
3245

3346
# 12.0.0-alpha.8
3447

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Make sure you have [opam](https://opam.ocaml.org/doc/Install.html) installed on
4747
opam init
4848

4949
# Any recent OCaml version works as a development compiler
50-
opam switch create 5.2.1 # can also create local switch with opam switch create
50+
opam switch create 5.3.0 # can also create local switch with opam switch create
5151

5252
# Install dev dependencies from OPAM
5353
opam install . --deps-only --with-test --with-dev-setup -y

Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ test-tools:
4040

4141
test-syntax:
4242
bash ./scripts/test_syntax.sh
43-
make reanalyze
4443
bash ./scripts/testok.sh
4544

4645
test-syntax-roundtrip:
4746
ROUNDTRIP_TEST=1 bash ./scripts/test_syntax.sh
48-
make reanalyze
4947
bash ./scripts/testok.sh
5048

5149
test-gentype:

analysis.opam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ license: "LGPL-3.0-or-later"
77
homepage: "https://github.com/rescript-lang/rescript-compiler"
88
bug-reports: "https://github.com/rescript-lang/rescript-compiler/issues"
99
depends: [
10-
"ocaml" {>= "4.10"}
11-
"cppo" {= "1.6.9"}
10+
"ocaml" {>= "4.14"}
11+
"cppo" {= "1.8.0"}
1212
"dune"
1313
]
1414
build: [

analysis/reanalyze/src/DeadCommon.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,8 @@ module Decl = struct
555555
let refIsBelow (pos : Lexing.position) =
556556
decl.pos.pos_fname <> pos.pos_fname
557557
|| decl.pos.pos_cnum < pos.pos_cnum
558-
&& (* not a function defined inside a function, e.g. not a callback *)
558+
&&
559+
(* not a function defined inside a function, e.g. not a callback *)
559560
decl.posEnd.pos_cnum < pos.pos_cnum
560561
in
561562
refs |> PosSet.exists refIsBelow

analysis/src/CompletionBackEnd.ml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,8 +1096,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10961096
*)
10971097
let completeAsBuiltin =
10981098
match typePath with
1099-
| Some t ->
1100-
TypeUtils.completionPathFromMaybeBuiltin t ~package:full.package
1099+
| Some t -> TypeUtils.completionPathFromMaybeBuiltin t
11011100
| None -> None
11021101
in
11031102
let completionPath =
@@ -1458,9 +1457,11 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
14581457
(* Special casing for things where we want extra things in the completions *)
14591458
let completionItems =
14601459
match path with
1461-
| Pdot (Pdot (Pident m, "Re", _), "t", _) when Ident.name m = "Js" ->
1460+
| Pdot (Pdot (Pident {name = "Js"}, "Re", _), "t", _)
1461+
| Pdot (Pdot (Pident {name = "Stdlib"}, "RegExp", _), "t", _)
1462+
| Pdot (Pident {name = "RegExp"}, "t", _) ->
14621463
(* regexps *)
1463-
create "%re()" ~insertText:"%re(\"/$0/g\")" ~includesSnippets:true
1464+
create "/<regexp>/g" ~insertText:"/$0/g" ~includesSnippets:true
14641465
~kind:(Label "Regular expression") ~env
14651466
:: completionItems
14661467
| _ -> completionItems
@@ -1807,8 +1808,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
18071808
if Debug.verbose () then print_endline "[complete_typed_value]--> Texn";
18081809
[
18091810
create
1810-
(full.package.builtInCompletionModules.exnModulePath @ ["Error(error)"]
1811-
|> ident)
1811+
(["Exn"; "Error(error)"] |> ident)
18121812
~kind:(Label "Catches errors from JavaScript errors.")
18131813
~docstring:
18141814
[
@@ -2250,12 +2250,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
22502250
| _ -> items)))
22512251
| CexhaustiveSwitch {contextPath; exprLoc} ->
22522252
let range = Utils.rangeOfLoc exprLoc in
2253-
let rescriptMajor, rescriptMinor = Packages.getReScriptVersion () in
2254-
let printFailwithStr num =
2255-
if (rescriptMajor = 11 && rescriptMinor >= 1) || rescriptMajor >= 12 then
2256-
"${" ^ string_of_int num ^ ":%todo}"
2257-
else "${" ^ string_of_int num ^ ":failwith(\"todo\")}"
2258-
in
2253+
let printFailwithStr num = "${" ^ string_of_int num ^ ":%todo}" in
22592254
let withExhaustiveItem ~cases ?(startIndex = 0) (c : Completion.t) =
22602255
(* We don't need to write out `switch` here since we know that's what the
22612256
user has already written. Just complete for the rest. *)

analysis/src/Packages.ml

Lines changed: 26 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -115,26 +115,35 @@ let newBsPackage ~rootPath =
115115
let path = [FindFiles.nameSpaceToName namespace] in
116116
[path]
117117
in
118+
let bind f x = Option.bind x f in
119+
let bsc_flags =
120+
Json.get "bsc-flags" config
121+
|> bind Json.array |> Option.value ~default:[]
122+
in
123+
let no_pervasives =
124+
bsc_flags
125+
|> List.exists (fun s -> Json.string s = Some "-nopervasives")
126+
in
118127
let opens_from_bsc_flags =
119-
let bind f x = Option.bind x f in
120-
match Json.get "bsc-flags" config |> bind Json.array with
121-
| Some l ->
122-
List.fold_left
123-
(fun opens item ->
124-
match item |> Json.string with
125-
| None -> opens
126-
| Some s -> (
127-
let parts = String.split_on_char ' ' s in
128-
match parts with
129-
| "-open" :: name :: _ ->
130-
let path = name |> String.split_on_char '.' in
131-
path :: opens
132-
| _ -> opens))
133-
[] l
134-
| None -> []
128+
List.fold_left
129+
(fun opens item ->
130+
match item |> Json.string with
131+
| None -> opens
132+
| Some s -> (
133+
let parts = String.split_on_char ' ' s in
134+
match parts with
135+
| "-open" :: name :: _ ->
136+
let path = name |> String.split_on_char '.' in
137+
path :: opens
138+
| _ -> opens))
139+
[] bsc_flags
140+
in
141+
let opens_from_pervasives =
142+
if no_pervasives then []
143+
else [["Stdlib"]; ["Pervasives"; "JsxModules"]]
135144
in
136145
let opens =
137-
["Pervasives"; "JsxModules"] :: opens_from_namespace
146+
opens_from_pervasives @ opens_from_namespace
138147
|> List.rev_append opens_from_bsc_flags
139148
|> List.map (fun path -> path @ ["place holder"])
140149
in
@@ -148,61 +157,6 @@ let newBsPackage ~rootPath =
148157
pathsForModule;
149158
opens;
150159
namespace;
151-
builtInCompletionModules =
152-
(if
153-
opens_from_bsc_flags
154-
|> List.find_opt (fun opn ->
155-
match opn with
156-
| ["RescriptCore"] -> true
157-
| _ -> false)
158-
|> Option.is_some
159-
|| fst rescriptVersion >= 12
160-
then
161-
{
162-
arrayModulePath = ["Array"];
163-
optionModulePath = ["Option"];
164-
stringModulePath = ["String"];
165-
intModulePath = ["Int"];
166-
floatModulePath = ["Float"];
167-
promiseModulePath = ["Promise"];
168-
listModulePath = ["List"];
169-
resultModulePath = ["Result"];
170-
exnModulePath = ["Exn"];
171-
regexpModulePath = ["RegExp"];
172-
}
173-
else if
174-
opens_from_bsc_flags
175-
|> List.find_opt (fun opn ->
176-
match opn with
177-
| ["Belt"] -> true
178-
| _ -> false)
179-
|> Option.is_some
180-
then
181-
{
182-
arrayModulePath = ["Array"];
183-
optionModulePath = ["Option"];
184-
stringModulePath = ["Js"; "String2"];
185-
intModulePath = ["Int"];
186-
floatModulePath = ["Float"];
187-
promiseModulePath = ["Js"; "Promise"];
188-
listModulePath = ["List"];
189-
resultModulePath = ["Result"];
190-
exnModulePath = ["Js"; "Exn"];
191-
regexpModulePath = ["Js"; "Re"];
192-
}
193-
else
194-
{
195-
arrayModulePath = ["Js"; "Array2"];
196-
optionModulePath = ["Belt"; "Option"];
197-
stringModulePath = ["Js"; "String2"];
198-
intModulePath = ["Belt"; "Int"];
199-
floatModulePath = ["Belt"; "Float"];
200-
promiseModulePath = ["Js"; "Promise"];
201-
listModulePath = ["Belt"; "List"];
202-
resultModulePath = ["Belt"; "Result"];
203-
exnModulePath = ["Js"; "Exn"];
204-
regexpModulePath = ["Js"; "Re"];
205-
});
206160
uncurried;
207161
}))
208162
| None -> None

0 commit comments

Comments
 (0)