Skip to content

Commit 18a7257

Browse files
committed
Format + changelog
1 parent 7d4af38 commit 18a7257

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Runtime: fix reading from the pseudo-filesystem (#1859)
1515
* Runtime: fix initialization of standard streams under Windows (#1849)
1616
* Compiler: fix stack overflow issues with double translation (#1869)
17+
* Lib: make the Wasm version of Json.output work with native ints and JavaScript objects (#1872)
1718

1819
# 6.0.1 (2025-02-07) - Lille
1920

lib/js_of_ocaml/json.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ let rec write b v =
116116
write_int64 b i
117117
| id -> failwith (Printf.sprintf "Json.output: unsupported custom value %s " id)
118118
else if t = Obj.abstract_tag
119-
then
120-
(* Presumably a JavaScript value *)
121-
Buffer.add_string b (Js.to_string (json##stringify v))
119+
then
120+
(* Presumably a JavaScript value *)
121+
Buffer.add_string b (Js.to_string (json##stringify v))
122122
else failwith (Printf.sprintf "Json.output: unsupported tag %d " t)
123123

124124
let to_json v =

lib/tests/test_json.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ let%expect_test _ =
6363
[%expect {| 2 |}]
6464

6565
let%expect_test "JavaScript object" =
66-
let x = object%js val x = 1 val y = Js.string "abcd" end in
66+
let x =
67+
object%js
68+
val x = 1
69+
70+
val y = Js.string "abcd"
71+
end
72+
in
6773
let s = Json.output x in
6874
let s1 = Js.to_string s in
6975
Printf.printf "%s\n" s1;

0 commit comments

Comments
 (0)