Skip to content

Commit 3f1f1e6

Browse files
authored
Merge pull request rescript-lang#6650 from cknitt/11-to-master
Merge changes from 11.0_release into master
2 parents 1bc9e03 + d951370 commit 3f1f1e6

14 files changed

+227
-78
lines changed

.github/workflows/ci.yml

+28-35
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-5.1.1-01
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-5.1.1-01
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-5.1.1-01
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

@@ -174,7 +167,7 @@ jobs:
174167
run: opam exec -- dune build --display quiet --profile release
175168

176169
- name: Use Node.js
177-
uses: actions/setup-node@v3
170+
uses: actions/setup-node@v4
178171
with:
179172
node-version: 16
180173

@@ -183,7 +176,7 @@ jobs:
183176

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

@@ -263,14 +256,14 @@ jobs:
263256
run: node .github/workflows/get_artifact_info.js
264257

265258
- name: "Upload artifacts: binaries"
266-
uses: actions/upload-artifact@v3
259+
uses: actions/upload-artifact@v4
267260
with:
268261
name: ${{ env.artifact_name }}
269262
path: ${{ env.artifact_path }}
270263

271264
- name: "Upload artifacts: lib/ocaml"
272265
if: runner.os == 'Linux'
273-
uses: actions/upload-artifact@v3
266+
uses: actions/upload-artifact@v4
274267
with:
275268
name: lib-ocaml
276269
path: lib/ocaml
@@ -281,18 +274,18 @@ jobs:
281274

282275
steps:
283276
- name: Checkout
284-
uses: actions/checkout@v3
277+
uses: actions/checkout@v4
285278

286279
- name: Use Node.js
287-
uses: actions/setup-node@v3
280+
uses: actions/setup-node@v4
288281
with:
289282
node-version: 16
290283

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

294287
- name: Download artifacts
295-
uses: actions/download-artifact@v3
288+
uses: actions/download-artifact@v4
296289

297290
- name: Move artifacts
298291
run: ./scripts/moveArtifacts.sh
@@ -315,7 +308,7 @@ jobs:
315308
run: node .github/workflows/prepare_package_upload.js ${{ github.event.pull_request.head.sha }}
316309

317310
- name: "Upload artifact: npm packages"
318-
uses: actions/upload-artifact@v3
311+
uses: actions/upload-artifact@v4
319312
with:
320313
name: npm-packages
321314
path: |
@@ -342,15 +335,15 @@ jobs:
342335

343336
steps:
344337
- name: Checkout
345-
uses: actions/checkout@v3
338+
uses: actions/checkout@v4
346339

347340
- name: Use Node.js
348-
uses: actions/setup-node@v3
341+
uses: actions/setup-node@v4
349342
with:
350343
node-version: 16
351344

352345
- name: Download artifacts
353-
uses: actions/download-artifact@v3
346+
uses: actions/download-artifact@v4
354347
with:
355348
name: npm-packages
356349
path: packages/test
@@ -374,16 +367,16 @@ jobs:
374367

375368
steps:
376369
- name: Checkout
377-
uses: actions/checkout@v3
370+
uses: actions/checkout@v4
378371

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

385378
- name: Download artifacts
386-
uses: actions/download-artifact@v3
379+
uses: actions/download-artifact@v4
387380
with:
388381
name: npm-packages
389382

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222

2323
- Build with OCaml 5.1.1. https://github.com/rescript-lang/rescript-compiler/pull/6641
2424

25+
# 11.1.0-rc.3
26+
27+
#### :nail_care: Polish
28+
29+
- No parens around tagged template literals. https://github.com/rescript-lang/rescript-compiler/pull/6639
30+
- 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
31+
32+
#### :bug: Bug Fix
33+
34+
- Fix compiler crash when reexporting tagged template literal externals. https://github.com/rescript-lang/rescript-compiler/pull/6645
35+
2536
# 11.1.0-rc.2
2637

2738
#### :rocket: New Feature
@@ -38,6 +49,7 @@
3849
- Generic JSX transform: Handle namespaced names. https://github.com/rescript-lang/rescript-compiler/pull/6606
3950
- Fix issue with doc comment in recursive module. https://github.com/rescript-lang/rescript-compiler/pull/6613
4051
- Fix issue with Exceptions and Extensible types runtime generation. https://github.com/rescript-lang/rescript-compiler/pull/6570
52+
- Fix inline comment before spread syntax in record. https://github.com/rescript-lang/rescript-compiler/pull/6615
4153

4254
#### :house: Internal
4355

jscomp/core/lam_compile_external_call.ml

+7-8
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

jscomp/syntax/src/res_core.ml

+10-9
Original file line numberDiff line numberDiff line change
@@ -2066,8 +2066,7 @@ and parsePrimaryExpr ~operand ?(noCall = false) p =
20662066
| Backtick
20672067
when noCall = false && p.prevEndPos.pos_lnum == p.startPos.pos_lnum -> (
20682068
match expr.pexp_desc with
2069-
| Pexp_ident {txt = Longident.Lident ident} ->
2070-
parseTemplateExpr ~prefix:ident p
2069+
| Pexp_ident long_ident -> parseTemplateExpr ~prefix:long_ident p
20712070
| _ ->
20722071
Parser.err ~startPos:expr.pexp_loc.loc_start
20732072
~endPos:expr.pexp_loc.loc_end p
@@ -2243,13 +2242,15 @@ and parseBinaryExpr ?(context = OrdinaryExpr) ?a p prec =
22432242
(* | _ -> false *)
22442243
(* ) *)
22452244

2246-
and parseTemplateExpr ?(prefix = "js") p =
2245+
and parseTemplateExpr ?prefix p =
22472246
let partPrefix =
22482247
(* we could stop treating js and j prefix as something special
22492248
for json, we would first need to remove @as(json`true`) feature *)
22502249
match prefix with
2251-
| "js" | "j" | "json" -> Some prefix
2252-
| _ -> None
2250+
| Some {txt = Longident.Lident (("js" | "j" | "json") as prefix); _} ->
2251+
Some prefix
2252+
| Some _ -> None
2253+
| None -> Some "js"
22532254
in
22542255
let startPos = p.Parser.startPos in
22552256

@@ -2286,8 +2287,7 @@ and parseTemplateExpr ?(prefix = "js") p =
22862287
let values = Ext_list.filter_map parts snd in
22872288
let endPos = p.Parser.endPos in
22882289

2289-
let genTaggedTemplateCall () =
2290-
let lident = Longident.Lident prefix in
2290+
let genTaggedTemplateCall lident =
22912291
let ident =
22922292
Ast_helper.Exp.ident ~attrs:[] ~loc:Location.none
22932293
(Location.mknoloc lident)
@@ -2338,8 +2338,9 @@ and parseTemplateExpr ?(prefix = "js") p =
23382338
in
23392339

23402340
match prefix with
2341-
| "js" | "j" | "json" -> genInterpolatedString ()
2342-
| _ -> genTaggedTemplateCall ()
2341+
| Some {txt = Longident.Lident ("js" | "j" | "json"); _} | None ->
2342+
genInterpolatedString ()
2343+
| Some {txt = lident} -> genTaggedTemplateCall lident
23432344

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

jscomp/syntax/src/res_parsetree_viewer.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ let filterParsingAttrs attrs =
224224
Location.txt =
225225
( "bs" | "res.uapp" | "res.arity" | "res.braces" | "ns.braces"
226226
| "res.iflet" | "res.namedArgLoc" | "res.optional" | "res.ternary"
227-
| "res.async" | "res.await" | "res.template" );
227+
| "res.async" | "res.await" | "res.template"
228+
| "res.taggedTemplate" );
228229
},
229230
_ ) ->
230231
false

jscomp/syntax/src/res_printer.ml

+17-7
Original file line numberDiff line numberDiff line change
@@ -2921,15 +2921,25 @@ and printExpression ~state (e : Parsetree.expression) cmtTbl =
29212921
let spread =
29222922
match spreadExpr with
29232923
| None -> Doc.nil
2924-
| Some expr ->
2924+
| Some ({pexp_desc} as expr) ->
2925+
let doc =
2926+
match pexp_desc with
2927+
| Pexp_ident {txt = expr} -> printLident expr
2928+
| _ -> printExpression ~state expr cmtTbl
2929+
in
2930+
let docWithSpread =
2931+
Doc.concat
2932+
[
2933+
Doc.dotdotdot;
2934+
(match Parens.expr expr with
2935+
| Parens.Parenthesized -> addParens doc
2936+
| Braced braces -> printBraces doc expr braces
2937+
| Nothing -> doc);
2938+
]
2939+
in
29252940
Doc.concat
29262941
[
2927-
Doc.dotdotdot;
2928-
(let doc = printExpressionWithComments ~state expr cmtTbl in
2929-
match Parens.expr expr with
2930-
| Parens.Parenthesized -> addParens doc
2931-
| Braced braces -> printBraces doc expr braces
2932-
| Nothing -> doc);
2942+
printComments docWithSpread cmtTbl expr.Parsetree.pexp_loc;
29332943
Doc.comma;
29342944
Doc.line;
29352945
]

jscomp/syntax/tests/printer/comments/expected/expr.res.txt

+41-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ let user = /* before */ {
122122
} // after
123123

124124
let spreadUser = {
125-
.../* before */ user1 /* after */,
125+
/* before */ ...user1 /* after */,
126126
/* c0 */ age /* c1 */: /* c2 */ 32 /* c3 */,
127127
}
128128

@@ -281,3 +281,43 @@ Doc.concat(list{
281281
rows,
282282
/* a */
283283
})
284+
285+
// More record spread test
286+
type b = {
287+
// spread a
288+
...a,
289+
// spread c
290+
...c,
291+
// no spread
292+
b: string,
293+
}
294+
295+
type a = {
296+
// spread from different module
297+
...M.a,
298+
// spread c
299+
...c,
300+
// no spread
301+
b: string,
302+
}
303+
304+
let b = {
305+
// exotic
306+
...\"let",
307+
// foo
308+
bar: "foo",
309+
}
310+
311+
let b = {
312+
// quote
313+
..."let",
314+
// foo
315+
bar: "foo",
316+
}
317+
318+
let c = {
319+
// from different module
320+
...M.a,
321+
// foo
322+
bar: "foo",
323+
}

0 commit comments

Comments
 (0)