Skip to content

Commit 2a30893

Browse files
authored
[interpreter] Fix JS module invocation (#1829)
1 parent 8e5f4ee commit 2a30893

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

interpreter/script/js.ml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,21 +614,24 @@ let rec of_result res =
614614
| EitherResult ress ->
615615
"[" ^ String.concat ", " (List.map of_result ress) ^ "]"
616616

617+
let of_module bs =
618+
"module(" ^ of_bytes bs ^ ")"
619+
617620
let rec of_definition def =
618621
match def.it with
619-
| Textual (m, _) -> of_bytes (Encode.encode m)
620-
| Encoded (_, bs) -> of_bytes bs.it
622+
| Textual (m, _) -> of_module (Encode.encode m)
623+
| Encoded (_, bs) -> of_module bs.it
621624
| Quoted (_, s) ->
622625
try of_definition (snd (Parse.Module.parse_string ~offset:s.at s.it))
623-
with Parse.Syntax _ | Custom.Syntax _ -> of_bytes "<malformed quote>"
626+
with Parse.Syntax _ | Custom.Syntax _ -> of_module "<malformed quote>"
624627

625628
let of_instance env x_opt =
626629
"instance(" ^ of_mod_opt env x_opt ^ ")"
627630

628631
let of_wrapper env x_opt name wrap_action wrap_assertion at =
629632
let x = of_inst_opt env x_opt in
630633
let bs = wrap name wrap_action wrap_assertion at in
631-
"call(instance(module(" ^ of_bytes bs ^ "), " ^
634+
"call(instance(" ^ of_module bs ^ ", " ^
632635
"exports(" ^ x ^ ")), " ^ " \"run\", [])"
633636

634637
let of_action env act =

0 commit comments

Comments
 (0)