Skip to content

Commit 1d4910a

Browse files
authored
Merge pull request #6596 from cknitt/11-to-master
Sync latest v11 changes to master
2 parents aa29841 + e4f834f commit 1d4910a

Some content is hidden

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

55 files changed

+620
-219
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [master, 11.0_release]
66
# See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
77
tags:
88
- "v[0-9]+.[0-9]+.[0-9]+"
99
- "v[0-9]+.[0-9]+.[0-9]+-*"
1010

1111
pull_request:
12-
branches: [master]
12+
branches: [master, 11.0_release]
1313

1414
concurrency:
1515
group: ci-${{ github.ref }}-1
@@ -109,7 +109,12 @@ jobs:
109109
strategy:
110110
fail-fast: false
111111
matrix:
112-
os: [macos-latest, ubuntu-latest, windows-latest, macos-arm]
112+
os: [
113+
macos-13, # x64
114+
macos-14, # ARM
115+
ubuntu-latest,
116+
windows-latest,
117+
]
113118
ocaml_compiler: [4.14.0]
114119

115120
runs-on: ${{matrix.os}}
@@ -230,24 +235,24 @@ jobs:
230235
if: runner.os == 'Windows'
231236
run: node scripts/ciTest.js -mocha -theme -format
232237

233-
# Build the playground compiler on our fastest runner (macOS ARM)
238+
# Build the playground compiler on the fastest runner (ubuntu-latest)
234239
- name: Install JSOO
235-
if: matrix.os == 'macos-arm'
240+
if: matrix.os == 'ubuntu-latest'
236241
run: opam install js_of_ocaml.4.0.0
237242

238243
- name: Build playground compiler
239-
if: matrix.os == 'macos-arm'
244+
if: matrix.os == 'ubuntu-latest'
240245
run: |
241246
opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js
242247
opam exec -- dune build --profile browser
243248
cp ./_build/default/jscomp/jsoo/jsoo_playground_main.bc.js playground/compiler.js
244249
245250
- name: Test playground compiler
246-
if: matrix.os == 'macos-arm'
251+
if: matrix.os == 'ubuntu-latest'
247252
run: node playground/playground_test.js
248253

249254
- name: Upload playground compiler to CDN
250-
if: ${{ matrix.os == 'macos-arm' && startsWith(github.ref, 'refs/tags/v') }}
255+
if: ${{ matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') }}
251256
env:
252257
KEYCDN_USER: ${{ secrets.KEYCDN_USER }}
253258
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
@@ -324,10 +329,9 @@ jobs:
324329
strategy:
325330
fail-fast: false
326331
matrix:
327-
os:
328-
[
329-
macos-latest,
330-
macos-arm,
332+
os: [
333+
macos-13, # x64
334+
macos-14, # ARM
331335
ubuntu-latest,
332336
buildjet-2vcpu-ubuntu-2204-arm,
333337
windows-latest,

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
1313
# 12.0.0-alpha.1 (Unreleased)
1414

15+
# 11.1.0-rc.1
16+
17+
#### :rocket: New Feature
18+
19+
- Experimental support of tagged template literals, e.g. ```sql`select * from ${table}```. https://github.com/rescript-lang/rescript-compiler/pull/6250
20+
- Experimental support for generic/custom JSX transforms. https://github.com/rescript-lang/rescript-compiler/pull/6565
21+
- `dict` is now a builtin type. https://github.com/rescript-lang/rescript-compiler/pull/6590
22+
23+
#### :bug: Bug Fix
24+
25+
- GenType: distinguish inline records from unary variant cases of object type. https://github.com/rescript-lang/rescript-compiler/pull/6586
26+
1527
# 11.0.1
1628

1729
#### :bug: Bug Fix

jscomp/bsb/bsb_jsx.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type version = Jsx_v3 | Jsx_v4
2-
type module_ = React
2+
type module_ = React | Generic of {moduleName: string}
33
type mode = Classic | Automatic
44
type dependencies = string list
55

@@ -15,7 +15,7 @@ let encode_no_nl jsx =
1515
| None -> ""
1616
| Some Jsx_v3 -> "3"
1717
| Some Jsx_v4 -> "4")
18-
^ (match jsx.module_ with None -> "" | Some React -> "React")
18+
^ (match jsx.module_ with None -> "" | Some React -> "React" | Some Generic {moduleName} -> moduleName)
1919
^
2020
match jsx.mode with
2121
| None -> ""
@@ -55,10 +55,10 @@ let from_map map =
5555
`Obj
5656
(fun m ->
5757
match m.?(Bsb_build_schemas.jsx_module) with
58-
| Some (Str { loc; str }) -> (
58+
| Some (Str { str }) -> (
5959
match str with
6060
| "react" -> module_ := Some React
61-
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str)
61+
| moduleName -> module_ := Some (Generic {moduleName}))
6262
| Some x ->
6363
Bsb_exception.config_error x
6464
"Unexpected input (jsx module name) for jsx module"

jscomp/bsb/bsb_ninja_rule.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
169169
| None, None -> ());
170170
(match jsx.module_ with
171171
| None -> ()
172-
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
172+
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react"
173+
| Some Generic {moduleName} -> Ext_buffer.add_string buf (" -bs-jsx-module " ^ moduleName));
173174
(match jsx.mode with
174175
| None -> ()
175176
| Some Classic -> Ext_buffer.add_string buf " -bs-jsx-mode classic"

jscomp/bsc/rescript_compiler_main.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
251251
"*internal* Set jsx version";
252252

253253
"-bs-jsx-module", string_call (fun i ->
254-
(if i <> "react" then Bsc_args.bad_arg (" Not supported jsx-module : " ^ i));
255254
Js_config.jsx_module := Js_config.jsx_module_of_string i),
256255
"*internal* Set jsx module";
257256

jscomp/common/js_config.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
(** Browser is not set via command line only for internal use *)
2626

2727
type jsx_version = Jsx_v3 | Jsx_v4
28-
type jsx_module = React
28+
type jsx_module = React | Generic of {moduleName: string}
2929
type jsx_mode = Classic | Automatic
3030

3131
let no_version_header = ref false
@@ -64,6 +64,7 @@ let int_of_jsx_version = function
6464

6565
let string_of_jsx_module = function
6666
| React -> "react"
67+
| Generic {moduleName} -> moduleName
6768

6869
let string_of_jsx_mode = function
6970
| Classic -> "classic"
@@ -76,7 +77,7 @@ let jsx_version_of_int = function
7677

7778
let jsx_module_of_string = function
7879
| "react" -> React
79-
| _ -> React
80+
| moduleName -> Generic {moduleName}
8081

8182
let jsx_mode_of_string = function
8283
| "classic" -> Classic

jscomp/common/js_config.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525
type jsx_version = Jsx_v3 | Jsx_v4
26-
type jsx_module = React
26+
type jsx_module = React | Generic of {moduleName: string}
2727
type jsx_mode = Classic | Automatic
2828

2929
(* val get_packages_info :

jscomp/core/j.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ and expression_desc =
115115
This can be constructed either in a static way [E.array_index_by_int] or a dynamic way
116116
[E.array_index]
117117
*)
118+
| Tagged_template of expression * expression list * expression list
118119
| Static_index of expression * string * int32 option
119120
(* The third argument bool indicates whether we should
120121
print it as

jscomp/core/js_analyzer.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
103103
| String_append (a, b) | Seq (a, b) -> no_side_effect a && no_side_effect b
104104
| Length (e, _) | Caml_block_tag (e, _) | Typeof e -> no_side_effect e
105105
| Bin (op, a, b) -> op <> Eq && no_side_effect a && no_side_effect b
106+
| Tagged_template (call_expr, strings, values) -> no_side_effect call_expr &&
107+
Ext_list.for_all strings no_side_effect && Ext_list.for_all values no_side_effect
106108
| Js_not _ | Cond _ | FlatCall _ | Call _ | New _ | Raw_js_code _
107109
(* actually true? *) ->
108110
false
@@ -204,7 +206,7 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
204206
| _ -> false)
205207
| Length _ | Is_null_or_undefined _ | String_append _ | Typeof _ | Js_not _
206208
| Cond _ | FlatCall _ | New _ | Fun _ | Raw_js_code _ | Array _
207-
| Caml_block_tag _ | Object _
209+
| Caml_block_tag _ | Object _ | Tagged_template _
208210
| Number (Uint _) ->
209211
false
210212
| Await _ -> false

jscomp/core/js_dump.ml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ let exp_need_paren (e : J.expression) =
165165
| Js_not _ | Bool _ | New _ ->
166166
false
167167
| Await _ -> false
168+
| Tagged_template _ -> false
168169

169170
let comma_idents (cxt : cxt) f ls = iter_lst cxt f ls Ext_pp_scope.ident comma
170171

@@ -596,6 +597,24 @@ and expression_desc cxt ~(level : int) f x : cxt =
596597
P.string f L.null;
597598
comma_sp f;
598599
expression ~level:1 cxt f el))
600+
| Tagged_template (callExpr, stringArgs, valueArgs) ->
601+
let cxt = expression cxt ~level f callExpr in
602+
P.string f "`";
603+
let rec aux cxt xs ys = match xs, ys with
604+
| [], [] -> ()
605+
| [{J.expression_desc = Str { txt; _ }}], [] ->
606+
P.string f txt
607+
| {J.expression_desc = Str { txt; _ }} :: x_rest, y :: y_rest ->
608+
P.string f txt;
609+
P.string f "${";
610+
let cxt = expression cxt ~level f y in
611+
P.string f "}";
612+
aux cxt x_rest y_rest
613+
| _ -> assert false
614+
in
615+
aux cxt stringArgs valueArgs;
616+
P.string f "`";
617+
cxt
599618
| String_index (a, b) ->
600619
P.group f 1 (fun _ ->
601620
let cxt = expression ~level:15 cxt f a in

jscomp/core/js_exp_make.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ let call ?comment ~info e0 args : t =
7272
let flat_call ?comment e0 es : t =
7373
{ expression_desc = FlatCall (e0, es); comment }
7474

75+
let tagged_template ?comment callExpr stringArgs valueArgs : t =
76+
{ expression_desc = Tagged_template (callExpr, stringArgs, valueArgs); comment }
77+
7578
let runtime_var_dot ?comment (x : string) (e1 : string) : J.expression =
7679
{
7780
expression_desc =

jscomp/core/js_exp_make.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ val call : ?comment:string -> info:Js_call_info.t -> t -> t list -> t
279279

280280
val flat_call : ?comment:string -> t -> t -> t
281281

282+
val tagged_template : ?comment:string -> t -> t list -> t list -> t
283+
282284
val new_ : ?comment:string -> J.expression -> J.expression list -> t
283285

284286
val array : ?comment:string -> J.mutable_flag -> J.expression list -> t

jscomp/core/js_fold.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ class fold =
124124
let _self = _self#expression _x0 in
125125
let _self = list (fun _self -> _self#expression) _self _x1 in
126126
_self
127+
| Tagged_template (_x0, _x1, _x2) ->
128+
let _self = _self#expression _x0 in
129+
let _self = list (fun _self -> _self#expression) _self _x1 in
130+
let _self = list (fun _self -> _self#expression) _self _x2 in
131+
_self
127132
| String_index (_x0, _x1) ->
128133
let _self = _self#expression _x0 in
129134
let _self = _self#expression _x1 in

jscomp/core/js_record_fold.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ let expression_desc : 'a. ('a, expression_desc) fn =
130130
let st = _self.expression _self st _x0 in
131131
let st = list _self.expression _self st _x1 in
132132
st
133+
| Tagged_template (_xo, _x1, _x2) ->
134+
let st = _self.expression _self st _xo in
135+
let st = list _self.expression _self st _x1 in
136+
let st = list _self.expression _self st _x2 in
137+
st
133138
| String_index (_x0, _x1) ->
134139
let st = _self.expression _self st _x0 in
135140
let st = _self.expression _self st _x1 in

jscomp/core/js_record_iter.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ let expression_desc : expression_desc fn =
107107
| Call (_x0, _x1, _x2) ->
108108
_self.expression _self _x0;
109109
list _self.expression _self _x1
110+
| Tagged_template (_x0, _x1, _x2) ->
111+
_self.expression _self _x0;
112+
list _self.expression _self _x1;
113+
list _self.expression _self _x2
110114
| String_index (_x0, _x1) ->
111115
_self.expression _self _x0;
112116
_self.expression _self _x1

jscomp/core/js_record_map.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ let expression_desc : expression_desc fn =
130130
let _x0 = _self.expression _self _x0 in
131131
let _x1 = list _self.expression _self _x1 in
132132
Call (_x0, _x1, _x2)
133+
| Tagged_template (_x0, _x1, _x2) ->
134+
let _x0 = _self.expression _self _x0 in
135+
let _x1 = list _self.expression _self _x1 in
136+
let _x2 = list _self.expression _self _x2 in
137+
Tagged_template (_x0, _x1, _x2)
133138
| String_index (_x0, _x1) ->
134139
let _x0 = _self.expression _self _x0 in
135140
let _x1 = _self.expression _self _x1 in

jscomp/core/lam_compile_external_call.ml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,17 @@ 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 = module_name; name = fn; splice; scopes } ->
255+
| Js_call { external_module_name; name; splice; scopes; tagged_template = true } ->
256+
let fn = translate_scoped_module_val external_module_name name scopes in
257+
(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)
265+
| Js_call { external_module_name = module_name; name = fn; splice; scopes; tagged_template = false } ->
256266
let fn = translate_scoped_module_val module_name fn scopes in
257267
if splice then
258268
let args, eff, dynamic = assemble_args_has_splice arg_types args in

0 commit comments

Comments
 (0)