Skip to content

Sync latest v11 changes to master #6596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f64a642
Set version to 11.0.1 (#6561)
cknitt Jan 12, 2024
6df7d2f
describe what branch to target when making PRs
tsnobip Jan 15, 2024
7ff004f
run CI on 11.0_release
tsnobip Jan 15, 2024
612fc40
format
tsnobip Jan 15, 2024
f7b146d
Merge pull request #6567 from rescript-lang/add_ci_to_release_branch
fhammerschmidt Jan 15, 2024
d2ccc4e
Use @rescript/react 0.12.0 for playground bundling and gentype test (…
cknitt Jan 17, 2024
0223607
Fix issue with recursive modules and uncurried.
cristianoc Jan 17, 2024
b2ae38a
fixed Not_found exception raised in certain coercion cases (#6574)
zth Jan 17, 2024
d69d438
Fix renamed field access in inline records (#6551)
tsnobip Jan 18, 2024
3151d66
Improve error message for missing label(s) in function application (#…
cknitt Jan 20, 2024
76f993a
ciTest.js: remove unused themeTest (#6577)
cknitt Jan 20, 2024
f0ef0ef
Update changelog (prepare for 11.0.1 release) (#6578)
cknitt Jan 20, 2024
b18a16b
Set version to 11.0.2 (#6580)
cknitt Jan 20, 2024
9f81707
Fix typo: Utililites -> Utilities (#6581)
cknitt Jan 23, 2024
6fa3289
support tagged templates (#6250)
tsnobip Jan 25, 2024
28b3b9a
GenType: distinguish inline records from unary variant cases of objec…
cristianoc Jan 26, 2024
b88e74f
[RFC] Generic JSX transform (#6565)
zth Jan 29, 2024
d206b2d
Dict as a builtin (#6590)
zth Jan 30, 2024
bd37a65
adapt build schema to new generic JSX transform (#6588)
zth Jan 29, 2024
3b291b2
Prepare for 11.1.0-rc.1 release
cknitt Jan 30, 2024
85336e0
Set version to 11.1.0-rc.2 (#6593)
cknitt Jan 31, 2024
579b9d7
Use Github-hosted macos arm runner (macos-14) (#6595)
cknitt Jan 31, 2024
e4f834f
Merge remote-tracking branch 'origin/11.0_release' into 11-to-master
cknitt Jan 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: CI

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

pull_request:
branches: [master]
branches: [master, 11.0_release]

concurrency:
group: ci-${{ github.ref }}-1
Expand Down Expand Up @@ -109,7 +109,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest, macos-arm]
os: [
macos-13, # x64
macos-14, # ARM
ubuntu-latest,
windows-latest,
]
ocaml_compiler: [4.14.0]

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

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

- name: Build playground compiler
if: matrix.os == 'macos-arm'
if: matrix.os == 'ubuntu-latest'
run: |
opam exec -- node packages/playground-bundling/scripts/generate_cmijs.js
opam exec -- dune build --profile browser
cp ./_build/default/jscomp/jsoo/jsoo_playground_main.bc.js playground/compiler.js

- name: Test playground compiler
if: matrix.os == 'macos-arm'
if: matrix.os == 'ubuntu-latest'
run: node playground/playground_test.js

- name: Upload playground compiler to CDN
if: ${{ matrix.os == 'macos-arm' && startsWith(github.ref, 'refs/tags/v') }}
if: ${{ matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/v') }}
env:
KEYCDN_USER: ${{ secrets.KEYCDN_USER }}
KEYCDN_PASSWORD: ${{ secrets.KEYCDN_PASSWORD }}
Expand Down Expand Up @@ -324,10 +329,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os:
[
macos-latest,
macos-arm,
os: [
macos-13, # x64
macos-14, # ARM
ubuntu-latest,
buildjet-2vcpu-ubuntu-2204-arm,
windows-latest,
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@

# 12.0.0-alpha.1 (Unreleased)

# 11.1.0-rc.1

#### :rocket: New Feature

- Experimental support of tagged template literals, e.g. ```sql`select * from ${table}```. https://github.com/rescript-lang/rescript-compiler/pull/6250
- Experimental support for generic/custom JSX transforms. https://github.com/rescript-lang/rescript-compiler/pull/6565
- `dict` is now a builtin type. https://github.com/rescript-lang/rescript-compiler/pull/6590

#### :bug: Bug Fix

- GenType: distinguish inline records from unary variant cases of object type. https://github.com/rescript-lang/rescript-compiler/pull/6586

# 11.0.1

#### :bug: Bug Fix
Expand Down
8 changes: 4 additions & 4 deletions jscomp/bsb/bsb_jsx.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type version = Jsx_v3 | Jsx_v4
type module_ = React
type module_ = React | Generic of {moduleName: string}
type mode = Classic | Automatic
type dependencies = string list

Expand All @@ -15,7 +15,7 @@ let encode_no_nl jsx =
| None -> ""
| Some Jsx_v3 -> "3"
| Some Jsx_v4 -> "4")
^ (match jsx.module_ with None -> "" | Some React -> "React")
^ (match jsx.module_ with None -> "" | Some React -> "React" | Some Generic {moduleName} -> moduleName)
^
match jsx.mode with
| None -> ""
Expand Down Expand Up @@ -55,10 +55,10 @@ let from_map map =
`Obj
(fun m ->
match m.?(Bsb_build_schemas.jsx_module) with
| Some (Str { loc; str }) -> (
| Some (Str { str }) -> (
match str with
| "react" -> module_ := Some React
| _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str)
| moduleName -> module_ := Some (Generic {moduleName}))
| Some x ->
Bsb_exception.config_error x
"Unexpected input (jsx module name) for jsx module"
Expand Down
3 changes: 2 additions & 1 deletion jscomp/bsb/bsb_ninja_rule.ml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ let make_custom_rules ~(gentype_config : Bsb_config_types.gentype_config)
| None, None -> ());
(match jsx.module_ with
| None -> ()
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react");
| Some React -> Ext_buffer.add_string buf " -bs-jsx-module react"
| Some Generic {moduleName} -> Ext_buffer.add_string buf (" -bs-jsx-module " ^ moduleName));
(match jsx.mode with
| None -> ()
| Some Classic -> Ext_buffer.add_string buf " -bs-jsx-mode classic"
Expand Down
1 change: 0 additions & 1 deletion jscomp/bsc/rescript_compiler_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ let buckle_script_flags : (string * Bsc_args.spec * string) array =
"*internal* Set jsx version";

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

Expand Down
5 changes: 3 additions & 2 deletions jscomp/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(** Browser is not set via command line only for internal use *)

type jsx_version = Jsx_v3 | Jsx_v4
type jsx_module = React
type jsx_module = React | Generic of {moduleName: string}
type jsx_mode = Classic | Automatic

let no_version_header = ref false
Expand Down Expand Up @@ -64,6 +64,7 @@ let int_of_jsx_version = function

let string_of_jsx_module = function
| React -> "react"
| Generic {moduleName} -> moduleName

let string_of_jsx_mode = function
| Classic -> "classic"
Expand All @@ -76,7 +77,7 @@ let jsx_version_of_int = function

let jsx_module_of_string = function
| "react" -> React
| _ -> React
| moduleName -> Generic {moduleName}

let jsx_mode_of_string = function
| "classic" -> Classic
Expand Down
2 changes: 1 addition & 1 deletion jscomp/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type jsx_version = Jsx_v3 | Jsx_v4
type jsx_module = React
type jsx_module = React | Generic of {moduleName: string}
type jsx_mode = Classic | Automatic

(* val get_packages_info :
Expand Down
1 change: 1 addition & 0 deletions jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ and expression_desc =
This can be constructed either in a static way [E.array_index_by_int] or a dynamic way
[E.array_index]
*)
| Tagged_template of expression * expression list * expression list
| Static_index of expression * string * int32 option
(* The third argument bool indicates whether we should
print it as
Expand Down
4 changes: 3 additions & 1 deletion jscomp/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ let rec no_side_effect_expression_desc (x : J.expression_desc) =
| String_append (a, b) | Seq (a, b) -> no_side_effect a && no_side_effect b
| Length (e, _) | Caml_block_tag (e, _) | Typeof e -> no_side_effect e
| Bin (op, a, b) -> op <> Eq && no_side_effect a && no_side_effect b
| Tagged_template (call_expr, strings, values) -> no_side_effect call_expr &&
Ext_list.for_all strings no_side_effect && Ext_list.for_all values no_side_effect
| Js_not _ | Cond _ | FlatCall _ | Call _ | New _ | Raw_js_code _
(* actually true? *) ->
false
Expand Down Expand Up @@ -204,7 +206,7 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
| _ -> false)
| Length _ | Is_null_or_undefined _ | String_append _ | Typeof _ | Js_not _
| Cond _ | FlatCall _ | New _ | Fun _ | Raw_js_code _ | Array _
| Caml_block_tag _ | Object _
| Caml_block_tag _ | Object _ | Tagged_template _
| Number (Uint _) ->
false
| Await _ -> false
Expand Down
19 changes: 19 additions & 0 deletions jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ let exp_need_paren (e : J.expression) =
| Js_not _ | Bool _ | New _ ->
false
| Await _ -> false
| Tagged_template _ -> false

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

Expand Down Expand Up @@ -596,6 +597,24 @@ and expression_desc cxt ~(level : int) f x : cxt =
P.string f L.null;
comma_sp f;
expression ~level:1 cxt f el))
| Tagged_template (callExpr, stringArgs, valueArgs) ->
let cxt = expression cxt ~level f callExpr in
P.string f "`";
let rec aux cxt xs ys = match xs, ys with
| [], [] -> ()
| [{J.expression_desc = Str { txt; _ }}], [] ->
P.string f txt
| {J.expression_desc = Str { txt; _ }} :: x_rest, y :: y_rest ->
P.string f txt;
P.string f "${";
let cxt = expression cxt ~level f y in
P.string f "}";
aux cxt x_rest y_rest
| _ -> assert false
in
aux cxt stringArgs valueArgs;
P.string f "`";
cxt
| String_index (a, b) ->
P.group f 1 (fun _ ->
let cxt = expression ~level:15 cxt f a in
Expand Down
3 changes: 3 additions & 0 deletions jscomp/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ let call ?comment ~info e0 args : t =
let flat_call ?comment e0 es : t =
{ expression_desc = FlatCall (e0, es); comment }

let tagged_template ?comment callExpr stringArgs valueArgs : t =
{ expression_desc = Tagged_template (callExpr, stringArgs, valueArgs); comment }

let runtime_var_dot ?comment (x : string) (e1 : string) : J.expression =
{
expression_desc =
Expand Down
2 changes: 2 additions & 0 deletions jscomp/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ val call : ?comment:string -> info:Js_call_info.t -> t -> t list -> t

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

val tagged_template : ?comment:string -> t -> t list -> t list -> t

val new_ : ?comment:string -> J.expression -> J.expression list -> t

val array : ?comment:string -> J.mutable_flag -> J.expression list -> t
Expand Down
5 changes: 5 additions & 0 deletions jscomp/core/js_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ class fold =
let _self = _self#expression _x0 in
let _self = list (fun _self -> _self#expression) _self _x1 in
_self
| Tagged_template (_x0, _x1, _x2) ->
let _self = _self#expression _x0 in
let _self = list (fun _self -> _self#expression) _self _x1 in
let _self = list (fun _self -> _self#expression) _self _x2 in
_self
| String_index (_x0, _x1) ->
let _self = _self#expression _x0 in
let _self = _self#expression _x1 in
Expand Down
5 changes: 5 additions & 0 deletions jscomp/core/js_record_fold.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ let expression_desc : 'a. ('a, expression_desc) fn =
let st = _self.expression _self st _x0 in
let st = list _self.expression _self st _x1 in
st
| Tagged_template (_xo, _x1, _x2) ->
let st = _self.expression _self st _xo in
let st = list _self.expression _self st _x1 in
let st = list _self.expression _self st _x2 in
st
| String_index (_x0, _x1) ->
let st = _self.expression _self st _x0 in
let st = _self.expression _self st _x1 in
Expand Down
4 changes: 4 additions & 0 deletions jscomp/core/js_record_iter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ let expression_desc : expression_desc fn =
| Call (_x0, _x1, _x2) ->
_self.expression _self _x0;
list _self.expression _self _x1
| Tagged_template (_x0, _x1, _x2) ->
_self.expression _self _x0;
list _self.expression _self _x1;
list _self.expression _self _x2
| String_index (_x0, _x1) ->
_self.expression _self _x0;
_self.expression _self _x1
Expand Down
5 changes: 5 additions & 0 deletions jscomp/core/js_record_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ let expression_desc : expression_desc fn =
let _x0 = _self.expression _self _x0 in
let _x1 = list _self.expression _self _x1 in
Call (_x0, _x1, _x2)
| Tagged_template (_x0, _x1, _x2) ->
let _x0 = _self.expression _self _x0 in
let _x1 = list _self.expression _self _x1 in
let _x2 = list _self.expression _self _x2 in
Tagged_template (_x0, _x1, _x2)
| String_index (_x0, _x1) ->
let _x0 = _self.expression _self _x0 in
let _x1 = _self.expression _self _x1 in
Expand Down
12 changes: 11 additions & 1 deletion jscomp/core/lam_compile_external_call.ml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ let translate_scoped_access scopes obj =
let translate_ffi (cxt : Lam_compile_context.t) arg_types
(ffi : External_ffi_types.external_spec) (args : J.expression list) =
match ffi with
| Js_call { external_module_name = module_name; name = fn; splice; scopes } ->
| Js_call { external_module_name; name; splice; scopes; tagged_template = true } ->
let fn = translate_scoped_module_val external_module_name name scopes in
(match args with
| [ stringArgs; valueArgs ] -> (
match (stringArgs, valueArgs) with
| ({expression_desc = Array (strings, _); _}, {expression_desc = Array (values, _); _}) ->
E.tagged_template fn strings values
| _ -> assert false
)
| _ -> assert false)
| Js_call { external_module_name = module_name; name = fn; splice; scopes; tagged_template = false } ->
let fn = translate_scoped_module_val module_name fn scopes in
if splice then
let args, eff, dynamic = assemble_args_has_splice arg_types args in
Expand Down
Loading