Skip to content

Commit dcad755

Browse files
authored
Merge branch '11.0_release' into fix/recover-broken-jsx-prop
2 parents 27f5a09 + 1f2d463 commit dcad755

16 files changed

+173
-76
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,22 @@ jobs:
3333

3434
runs-on: ${{matrix.os}}
3535

36-
container:
37-
image: ghcr.io/rescript-lang/rescript-ci-build:alpine-3.19-ocaml-4.14.1-02
38-
3936
steps:
40-
# See https://github.com/actions/runner/issues/801#issuecomment-1374967227.
41-
- name: Workaround for Github actions runner on Alpine arm64
42-
if: runner.arch == 'ARM64'
43-
run: sed -i "s:ID=alpine:ID=NotpineForGHA:" /etc/os-release
44-
4537
- name: Checkout
46-
uses: actions/checkout@v3
38+
uses: actions/checkout@v4
4739

4840
- name: Build compiler binaries
49-
run: opam exec -- dune build --display quiet --profile static
41+
uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.19-ocaml-4.14.1-02
42+
with:
43+
args: opam exec -- dune build --display quiet --profile static
5044

5145
- name: Build ninja binary
52-
working-directory: ninja
53-
env:
54-
LDFLAGS: -static
55-
run: python3 configure.py --bootstrap --verbose
46+
uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.19-ocaml-4.14.1-02
47+
with:
48+
args: sh -c "cd ninja && LDFLAGS=-static python3 configure.py --bootstrap"
5649

5750
- name: "Upload artifacts"
58-
uses: actions/upload-artifact@v3
51+
uses: actions/upload-artifact@v4
5952
with:
6053
name: static-binaries-linux-${{runner.arch}}
6154
path: |
@@ -72,11 +65,11 @@ jobs:
7265

7366
steps:
7467
- name: Checkout
75-
uses: actions/checkout@v3
68+
uses: actions/checkout@v4
7669

7770
- name: Download static linux binaries
7871
if: runner.os == 'Linux'
79-
uses: actions/download-artifact@v3
72+
uses: actions/download-artifact@v4
8073
with:
8174
name: static-binaries-linux-${{ runner.arch }}
8275

@@ -87,7 +80,7 @@ jobs:
8780
chmod +x _build/install/default/bin/*
8881
8982
- name: Use Node.js
90-
uses: actions/setup-node@v3
83+
uses: actions/setup-node@v4
9184
with:
9285
node-version: 16
9386

@@ -98,7 +91,7 @@ jobs:
9891
run: node .github/workflows/get_artifact_info.js
9992

10093
- name: "Upload artifacts: binaries"
101-
uses: actions/upload-artifact@v3
94+
uses: actions/upload-artifact@v4
10295
with:
10396
name: ${{ env.artifact_name }}
10497
path: ${{ env.artifact_path }}
@@ -130,13 +123,13 @@ jobs:
130123
git config --global core.eol lf
131124
132125
- name: Checkout
133-
uses: actions/checkout@v3
126+
uses: actions/checkout@v4
134127
with:
135128
fetch-depth: 2 # to be able to check for changes in subfolder jscomp/syntax later
136129

137130
- name: Download static linux binaries
138131
if: runner.os == 'Linux'
139-
uses: actions/download-artifact@v3
132+
uses: actions/download-artifact@v4
140133
with:
141134
name: static-binaries-linux-${{ runner.arch }}
142135

@@ -173,7 +166,7 @@ jobs:
173166
run: opam exec -- dune build --display quiet --profile release
174167

175168
- name: Use Node.js
176-
uses: actions/setup-node@v3
169+
uses: actions/setup-node@v4
177170
with:
178171
node-version: 16
179172

@@ -182,7 +175,7 @@ jobs:
182175

183176
- name: "Windows: Use MSVC for ninja build"
184177
if: runner.os == 'Windows'
185-
uses: TheMrMilchmann/setup-msvc-dev@v2
178+
uses: TheMrMilchmann/setup-msvc-dev@v3
186179
with:
187180
arch: x64
188181

@@ -262,14 +255,14 @@ jobs:
262255
run: node .github/workflows/get_artifact_info.js
263256

264257
- name: "Upload artifacts: binaries"
265-
uses: actions/upload-artifact@v3
258+
uses: actions/upload-artifact@v4
266259
with:
267260
name: ${{ env.artifact_name }}
268261
path: ${{ env.artifact_path }}
269262

270263
- name: "Upload artifacts: lib/ocaml"
271264
if: runner.os == 'Linux'
272-
uses: actions/upload-artifact@v3
265+
uses: actions/upload-artifact@v4
273266
with:
274267
name: lib-ocaml
275268
path: lib/ocaml
@@ -280,18 +273,18 @@ jobs:
280273

281274
steps:
282275
- name: Checkout
283-
uses: actions/checkout@v3
276+
uses: actions/checkout@v4
284277

285278
- name: Use Node.js
286-
uses: actions/setup-node@v3
279+
uses: actions/setup-node@v4
287280
with:
288281
node-version: 16
289282

290283
- name: NPM install
291284
run: npm ci --ignore-scripts
292285

293286
- name: Download artifacts
294-
uses: actions/download-artifact@v3
287+
uses: actions/download-artifact@v4
295288

296289
- name: Move artifacts
297290
run: ./scripts/moveArtifacts.sh
@@ -314,7 +307,7 @@ jobs:
314307
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
315308

316309
- name: "Upload artifact: npm packages"
317-
uses: actions/upload-artifact@v3
310+
uses: actions/upload-artifact@v4
318311
with:
319312
name: npm-packages
320313
path: |
@@ -341,15 +334,15 @@ jobs:
341334

342335
steps:
343336
- name: Checkout
344-
uses: actions/checkout@v3
337+
uses: actions/checkout@v4
345338

346339
- name: Use Node.js
347-
uses: actions/setup-node@v3
340+
uses: actions/setup-node@v4
348341
with:
349342
node-version: 16
350343

351344
- name: Download artifacts
352-
uses: actions/download-artifact@v3
345+
uses: actions/download-artifact@v4
353346
with:
354347
name: npm-packages
355348
path: packages/test
@@ -373,16 +366,16 @@ jobs:
373366

374367
steps:
375368
- name: Checkout
376-
uses: actions/checkout@v3
369+
uses: actions/checkout@v4
377370

378371
- name: Use Node.js
379-
uses: actions/setup-node@v3
372+
uses: actions/setup-node@v4
380373
with:
381374
node-version: 16
382375
registry-url: https://registry.npmjs.org # Needed to make auth work for publishing
383376

384377
- name: Download artifacts
385-
uses: actions/download-artifact@v3
378+
uses: actions/download-artifact@v4
386379
with:
387380
name: npm-packages
388381

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,21 @@
1010
> - :house: [Internal]
1111
> - :nail_care: [Polish]
1212
13-
# 11.1.0-rc.3 (Unreleased)
13+
# 11.1.0-rc.4 (Unreleased)
14+
15+
#### :nail-care: Polish
16+
- Omit `undefined` in external function calls for trailing optional arguments when not supplied. https://github.com/rescript-lang/rescript-compiler/pull/6653
17+
18+
# 11.1.0-rc.3
19+
20+
#### :nail_care: Polish
21+
22+
- No parens around tagged template literals. https://github.com/rescript-lang/rescript-compiler/pull/6639
23+
- Allow identifier with modules in tagged template literals (e.g. Pg.sql`select * from ${table} where id = ${id}`). https://github.com/rescript-lang/rescript-compiler/pull/6645
24+
25+
#### :bug: Bug Fix
26+
27+
- Fix compiler crash when reexporting tagged template literal externals. https://github.com/rescript-lang/rescript-compiler/pull/6645
1428

1529
# 11.1.0-rc.2
1630

jscomp/common/bs_version.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
* You should have received a copy of the GNU Lesser General Public License
2222
* along with this program; if not, write to the Free Software
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24-
let version = "11.1.0-rc.3"
24+
let version = "11.1.0-rc.4"
2525
let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
2626
let package_name = ref "rescript"

jscomp/core/lam_compile_external_call.ml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,16 +252,15 @@ let translate_scoped_access scopes obj =
252252
let translate_ffi (cxt : Lam_compile_context.t) arg_types
253253
(ffi : External_ffi_types.external_spec) (args : J.expression list) =
254254
match ffi with
255-
| Js_call { external_module_name; name; splice; scopes; tagged_template = true } ->
255+
| Js_call { external_module_name; name; splice: _; scopes; tagged_template = true } ->
256256
let fn = translate_scoped_module_val external_module_name name scopes in
257257
(match args with
258-
| [ stringArgs; valueArgs ] -> (
259-
match (stringArgs, valueArgs) with
260-
| ({expression_desc = Array (strings, _); _}, {expression_desc = Array (values, _); _}) ->
261-
E.tagged_template fn strings values
262-
| _ -> assert false
263-
)
264-
| _ -> assert false)
258+
| [ {expression_desc = Array (strings, _); _}; {expression_desc = Array (values, _); _} ] ->
259+
E.tagged_template fn strings values
260+
| _ -> let args, eff, dynamic = assemble_args_has_splice arg_types args in
261+
add_eff eff
262+
(if dynamic then splice_apply fn args
263+
else E.call ~info:{ arity = Full; call_info = Call_na } fn args))
265264
| Js_call { external_module_name = module_name; name = fn; splice; scopes; tagged_template = false } ->
266265
let fn = translate_scoped_module_val module_name fn scopes in
267266
if splice then
@@ -271,6 +270,16 @@ let translate_ffi (cxt : Lam_compile_context.t) arg_types
271270
else E.call ~info:{ arity = Full; call_info = Call_na } fn args)
272271
else
273272
let args, eff = assemble_args_no_splice arg_types args in
273+
let rec keepNonUndefinedArgs argsList (argTypes : specs) =
274+
match (argsList, argTypes) with
275+
| ( {J.expression_desc = Undefined {isUnit = false}; _} :: rest,
276+
{External_arg_spec.arg_label = Arg_optional; _} :: argTypes ) ->
277+
keepNonUndefinedArgs rest argTypes
278+
| _ -> argsList
279+
in
280+
let args =
281+
keepNonUndefinedArgs (List.rev args) (List.rev arg_types) |> List.rev
282+
in
274283
add_eff eff
275284
@@ E.call ~info:{ arity = Full; call_info = Call_na } fn args
276285
| Js_module_as_fn { external_module_name; splice } ->

jscomp/syntax/src/res_core.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,8 +2140,7 @@ and parsePrimaryExpr ~operand ?(noCall = false) p =
21402140
| Backtick
21412141
when noCall = false && p.prevEndPos.pos_lnum == p.startPos.pos_lnum -> (
21422142
match expr.pexp_desc with
2143-
| Pexp_ident {txt = Longident.Lident ident} ->
2144-
parseTemplateExpr ~prefix:ident p
2143+
| Pexp_ident long_ident -> parseTemplateExpr ~prefix:long_ident p
21452144
| _ ->
21462145
Parser.err ~startPos:expr.pexp_loc.loc_start
21472146
~endPos:expr.pexp_loc.loc_end p
@@ -2322,13 +2321,15 @@ and parseBinaryExpr ?(context = OrdinaryExpr) ?a p prec =
23222321
(* | _ -> false *)
23232322
(* ) *)
23242323

2325-
and parseTemplateExpr ?(prefix = "js") p =
2324+
and parseTemplateExpr ?prefix p =
23262325
let partPrefix =
23272326
(* we could stop treating js and j prefix as something special
23282327
for json, we would first need to remove @as(json`true`) feature *)
23292328
match prefix with
2330-
| "js" | "j" | "json" -> Some prefix
2331-
| _ -> None
2329+
| Some {txt = Longident.Lident (("js" | "j" | "json") as prefix); _} ->
2330+
Some prefix
2331+
| Some _ -> None
2332+
| None -> Some "js"
23322333
in
23332334
let startPos = p.Parser.startPos in
23342335

@@ -2365,8 +2366,7 @@ and parseTemplateExpr ?(prefix = "js") p =
23652366
let values = Ext_list.filter_map parts snd in
23662367
let endPos = p.Parser.endPos in
23672368

2368-
let genTaggedTemplateCall () =
2369-
let lident = Longident.Lident prefix in
2369+
let genTaggedTemplateCall lident =
23702370
let ident =
23712371
Ast_helper.Exp.ident ~attrs:[] ~loc:Location.none
23722372
(Location.mknoloc lident)
@@ -2417,8 +2417,9 @@ and parseTemplateExpr ?(prefix = "js") p =
24172417
in
24182418

24192419
match prefix with
2420-
| "js" | "j" | "json" -> genInterpolatedString ()
2421-
| _ -> genTaggedTemplateCall ()
2420+
| Some {txt = Longident.Lident ("js" | "j" | "json"); _} | None ->
2421+
genInterpolatedString ()
2422+
| Some {txt = lident} -> genTaggedTemplateCall lident
24222423

24232424
(* Overparse: let f = a : int => a + 1, is it (a : int) => or (a): int =>
24242425
* Also overparse constraints:

jscomp/syntax/tests/printer/other/expected/string.res.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ let heart = "\u2665"
1717
let smile = "emoji: \u{1F600}"
1818

1919
let taggedTemplate = sql`select * from ${table} where id = ${id}`
20+
21+
let taggedTemplate = Pg.sql`select * from ${table} where id = ${id}`

jscomp/syntax/tests/printer/other/string.res

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ let heart = "\u2665"
1616

1717
let smile = "emoji: \u{1F600}"
1818

19-
let taggedTemplate = sql`select * from ${table} where id = ${id}`
19+
let taggedTemplate = sql`select * from ${table} where id = ${id}`
20+
21+
let taggedTemplate = Pg.sql`select * from ${table} where id = ${id}`

jscomp/test/build.ninja

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

jscomp/test/omit_trailing_undefined_in_external_calls.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@@uncurried
2+
3+
type dateFormatOptions = {someOption?: bool}
4+
5+
@module("SomeModule")
6+
external formatDate: (Js.Date.t, ~options: dateFormatOptions=?, ~done: bool=?) => string =
7+
"formatDate"
8+
9+
let x = formatDate(Js.Date.make())
10+
let x = formatDate(Js.Date.make(), ~options={someOption: true})
11+
let x = formatDate(Js.Date.make(), ~done=true)

0 commit comments

Comments
 (0)