Skip to content

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

Open
jchavarri wants to merge 3 commits intomainfrom
polyvar-no-tag
Open

Fix unused-var warning with polyvars without own cases#38
jchavarri wants to merge 3 commits intomainfrom
polyvar-no-tag

Conversation

@jchavarri
Copy link
Member

The case type poly = [ one | other ] triggers a:

Warning 26 [unused-var]: unused variable tag.

on the js generated code. This PR fixes it.

  • The first commit adds a test to show the generated code as is in main
  • The second commit fixes the problem and updates the test. The fix is just move the let tag definition inside the polyvar body expr

@jchavarri jchavarri requested a review from andreypopp November 21, 2024 18:41
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here was the problem: tag is never used below.

@andreypopp
Copy link
Collaborator

Let’s land #32 first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants