Skip to content

Commit eb7ebfc

Browse files
committed
fix reexport of tagged template externals
1 parent 9f9b421 commit eb7ebfc

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#### :nail_care: Polish
1616
- No parens around tagged template literals. https://github.com/rescript-lang/rescript-compiler/pull/6639
1717

18+
#### :bug: Bug Fix
19+
20+
- Fix compiler crash when reexporting tagged template literal externals. https://github.com/rescript-lang/rescript-compiler/pull/6645
21+
1822
# 11.1.0-rc.2
1923

2024
#### :rocket: New Feature

jscomp/core/lam_compile_external_call.ml

Lines changed: 7 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

jscomp/test/build.ninja

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,7 @@ o test/submodule.cmi test/submodule.cmj : cc test/submodule.res | $bsc $stdlib r
576576
o test/submodule_call.cmi test/submodule_call.cmj : cc test/submodule_call.res | test/submodule.cmj $bsc $stdlib runtime
577577
o test/switch_case_test.cmi test/switch_case_test.cmj : cc test/switch_case_test.res | test/mt.cmj $bsc $stdlib runtime
578578
o test/switch_string.cmi test/switch_string.cmj : cc test/switch_string.res | $bsc $stdlib runtime
579-
o test/tagged_template_test.cmj : cc_cmi test/tagged_template_test.res | test/mt.cmj test/tagged_template_test.cmi $bsc $stdlib runtime
580-
o test/tagged_template_test.cmi : cc test/tagged_template_test.resi | $bsc $stdlib runtime
579+
o test/tagged_template_test.cmi test/tagged_template_test.cmj : cc test/tagged_template_test.res | test/mt.cmj $bsc $stdlib runtime
581580
o test/tailcall_inline_test.cmi test/tailcall_inline_test.cmj : cc test/tailcall_inline_test.res | test/mt.cmj $bsc $stdlib runtime
582581
o test/template.cmi test/template.cmj : cc test/template.res | $bsc $stdlib runtime
583582
o test/test.cmi test/test.cmj : cc test/test.res | $bsc $stdlib runtime

jscomp/test/tagged_template_test.js

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jscomp/test/tagged_template_test.resi

Whitespace-only changes.

0 commit comments

Comments
 (0)