Skip to content

Commit

Permalink
qualify usages of not
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Aug 26, 2024
1 parent ca1b51d commit d2f8497
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
7 changes: 4 additions & 3 deletions ppx/browser/ppx_deriving_json_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ module Of_json = struct
Stdlib.( && )
(Stdlib.( = ) (Js.typeof [%e x]) "object")
(Stdlib.( && )
(not (Js.Array.isArray [%e x]))
(not (Stdlib.( == ) (Obj.magic [%e x] : 'a Js.null) Js.null)))]
(Stdlib.not (Js.Array.isArray [%e x]))
(Stdlib.not
(Stdlib.( == ) (Obj.magic [%e x] : 'a Js.null) Js.null)))]

let ensure_json_object ~loc x =
[%expr
if not [%e eis_json_object ~loc x] then
if Stdlib.not [%e eis_json_object ~loc x] then
Ppx_deriving_json_runtime.of_json_error
[%e estring ~loc (sprintf "expected a JSON object")]]

Expand Down
40 changes: 22 additions & 18 deletions ppx/test/ppx_deriving_json_js.t
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@
let rec record_of_json =
(fun x ->
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof x) "object")
(Stdlib.( && )
(not (Js.Array.isArray x))
(not (Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
(Stdlib.not (Js.Array.isArray x))
(Stdlib.not
(Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
then
Ppx_deriving_json_runtime.of_json_error "expected a JSON object";
let fs =
Expand Down Expand Up @@ -183,12 +184,13 @@
let rec record_aliased_of_json =
(fun x ->
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof x) "object")
(Stdlib.( && )
(not (Js.Array.isArray x))
(not (Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
(Stdlib.not (Js.Array.isArray x))
(Stdlib.not
(Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
then
Ppx_deriving_json_runtime.of_json_error "expected a JSON object";
let fs =
Expand Down Expand Up @@ -244,12 +246,13 @@
let rec record_opt_of_json =
(fun x ->
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof x) "object")
(Stdlib.( && )
(not (Js.Array.isArray x))
(not (Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
(Stdlib.not (Js.Array.isArray x))
(Stdlib.not
(Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
then
Ppx_deriving_json_runtime.of_json_error "expected a JSON object";
let fs = (Obj.magic x : < k : Js.Json.t Js.undefined > Js.t) in
Expand Down Expand Up @@ -311,12 +314,12 @@
"expected a JSON array of length 2";
let fs = Js.Array.unsafe_get array 1 in
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof fs) "object")
(Stdlib.( && )
(not (Js.Array.isArray fs))
(not
(Stdlib.not (Js.Array.isArray fs))
(Stdlib.not
(Stdlib.( == )
(Obj.magic fs : 'a Js.null)
Js.null))))
Expand Down Expand Up @@ -796,12 +799,13 @@
let rec allow_extra_fields_of_json =
(fun x ->
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof x) "object")
(Stdlib.( && )
(not (Js.Array.isArray x))
(not (Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
(Stdlib.not (Js.Array.isArray x))
(Stdlib.not
(Stdlib.( == ) (Obj.magic x : 'a Js.null) Js.null))))
then
Ppx_deriving_json_runtime.of_json_error "expected a JSON object";
let fs = (Obj.magic x : < a : Js.Json.t Js.undefined > Js.t) in
Expand Down Expand Up @@ -855,12 +859,12 @@
"expected a JSON array of length 2";
let fs = Js.Array.unsafe_get array 1 in
if
not
Stdlib.not
(Stdlib.( && )
(Stdlib.( = ) (Js.typeof fs) "object")
(Stdlib.( && )
(not (Js.Array.isArray fs))
(not
(Stdlib.not (Js.Array.isArray fs))
(Stdlib.not
(Stdlib.( == )
(Obj.magic fs : 'a Js.null)
Js.null))))
Expand Down

0 comments on commit d2f8497

Please sign in to comment.