Skip to content

Commit 9b96ef1

Browse files
committed
Merge branch 'master' into jsx-ast
2 parents e947779 + fd1e7b8 commit 9b96ef1

File tree

398 files changed

+5012
-3472
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

+5012
-3472
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 & 0 deletions
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,10 +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
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
2738

2839
#### :house: Internal
2940

3041
- 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
3145

3246
# 12.0.0-alpha.8
3347

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: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
979979
path @ [fieldName]
980980
|> getCompletionsForPath ~debug ~opens ~full ~pos ~exact
981981
~completionContext:Field ~env ~scope
982-
| CPField {contextPath = cp; fieldName; posOfDot; exprLoc} -> (
982+
| CPField {contextPath = cp; fieldName; posOfDot; exprLoc; inJsx} -> (
983983
if Debug.verbose () then print_endline "[dot_completion]--> Triggered";
984984
let completionsFromCtxPath =
985985
cp
@@ -1013,7 +1013,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10131013
CPApply (cp, [Asttypes.Noloc.Nolabel])
10141014
| _ -> cp);
10151015
id = fieldName;
1016-
inJsx = false;
1016+
inJsx;
10171017
lhsLoc = exprLoc;
10181018
}
10191019
in
@@ -1090,8 +1090,7 @@ and getCompletionsForContextPath ~debug ~full ~opens ~rawOpens ~pos ~env ~exact
10901090
*)
10911091
let completeAsBuiltin =
10921092
match typePath with
1093-
| Some t ->
1094-
TypeUtils.completionPathFromMaybeBuiltin t ~package:full.package
1093+
| Some t -> TypeUtils.completionPathFromMaybeBuiltin t
10951094
| None -> None
10961095
in
10971096
let completionPath =
@@ -1452,9 +1451,11 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
14521451
(* Special casing for things where we want extra things in the completions *)
14531452
let completionItems =
14541453
match path with
1455-
| Pdot (Pdot (Pident m, "Re", _), "t", _) when Ident.name m = "Js" ->
1454+
| Pdot (Pdot (Pident {name = "Js"}, "Re", _), "t", _)
1455+
| Pdot (Pdot (Pident {name = "Stdlib"}, "RegExp", _), "t", _)
1456+
| Pdot (Pident {name = "RegExp"}, "t", _) ->
14561457
(* regexps *)
1457-
create "%re()" ~insertText:"%re(\"/$0/g\")" ~includesSnippets:true
1458+
create "/<regexp>/g" ~insertText:"/$0/g" ~includesSnippets:true
14581459
~kind:(Label "Regular expression") ~env
14591460
:: completionItems
14601461
| _ -> completionItems
@@ -1801,8 +1802,7 @@ let rec completeTypedValue ?(typeArgContext : typeArgContext option) ~rawOpens
18011802
if Debug.verbose () then print_endline "[complete_typed_value]--> Texn";
18021803
[
18031804
create
1804-
(full.package.builtInCompletionModules.exnModulePath @ ["Error(error)"]
1805-
|> ident)
1805+
(["Exn"; "Error(error)"] |> ident)
18061806
~kind:(Label "Catches errors from JavaScript errors.")
18071807
~docstring:
18081808
[
@@ -2244,12 +2244,7 @@ let rec processCompletable ~debug ~full ~scope ~env ~pos ~forHover completable =
22442244
| _ -> items)))
22452245
| CexhaustiveSwitch {contextPath; exprLoc} ->
22462246
let range = Utils.rangeOfLoc exprLoc in
2247-
let rescriptMajor, rescriptMinor = Packages.getReScriptVersion () in
2248-
let printFailwithStr num =
2249-
if (rescriptMajor = 11 && rescriptMinor >= 1) || rescriptMajor >= 12 then
2250-
"${" ^ string_of_int num ^ ":%todo}"
2251-
else "${" ^ string_of_int num ^ ":failwith(\"todo\")}"
2252-
in
2247+
let printFailwithStr num = "${" ^ string_of_int num ^ ":%todo}" in
22532248
let withExhaustiveItem ~cases ?(startIndex = 0) (c : Completion.t) =
22542249
(* We don't need to write out `switch` here since we know that's what the
22552250
user has already written. Just complete for the rest. *)

0 commit comments

Comments
 (0)