Skip to content
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

Fix unused-var warning with polyvars without own cases #38

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
([#35](https://github.com/melange-community/melange-json/pull/35))
- PPX: Add array functions to native runtime
([#37](https://github.com/melange-community/melange-json/pull/37))
- PPX: Fix `unused-var` warning with polyvars without own cases
([#38](https://github.com/melange-community/melange-json/pull/38))

## 1.3.0 (2024-08-28)

Expand Down
3 changes: 2 additions & 1 deletion ppx/browser/ppx_deriving_json_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ module Of_json = struct
if Stdlib.( > ) len 0 then
let tag = Js.Array.unsafe_get array 0 in
if Stdlib.( = ) (Js.typeof tag) "string" then
let tag = (Obj.magic tag : string) in
[%e body]
else
Ppx_deriving_json_runtime.of_json_error
Expand All @@ -127,6 +126,7 @@ module Of_json = struct
let loc = n.loc in
let n = Option.value ~default:n (vcs_attr_json_name r.rcd_ctx) in
[%expr
let tag = (Obj.magic tag : string) in
if Stdlib.( = ) tag [%e estring ~loc:n.loc n.txt] then (
[%e ensure_json_array_len ~loc 2 [%expr len]];
let fs = Js.Array.unsafe_get array 1 in
Expand All @@ -140,6 +140,7 @@ module Of_json = struct
let n = Option.value ~default:n (vcs_attr_json_name t.tpl_ctx) in
let arity = List.length t.tpl_types in
[%expr
let tag = (Obj.magic tag : string) in
if Stdlib.( = ) tag [%e estring ~loc:n.loc n.txt] then (
[%e ensure_json_array_len ~loc (arity + 1) [%expr len]];
[%e
Expand Down
Loading