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 warning #1

Open
saleyn opened this issue Feb 25, 2022 · 0 comments
Open

Fix warning #1

saleyn opened this issue Feb 25, 2022 · 0 comments

Comments

@saleyn
Copy link
Owner

saleyn commented Feb 25, 2022

With listcomp parse transform, when compiling the following code:

[{Idx,I} || Idx, {req, FF} <- [{req, [10,20,30]}], I <- FF]

it produces the warning: Warning: variable 'FF' is unused.

This is because the code gets transformed into:

element(1,
            lists:mapfoldl(fun ({_I@5_54 = {req, FF}, I}, Idx) ->
                                   {{Idx, I}, Idx + 1}
                           end,
                           1,
                           [{_I@5_54, I}
                            || _I@5_54 = {req, FF} <- [{req, [10, 20, 30]}],
                               I <- FF]))

where the FF variable in the lambda is unused in its body. The solution is to check the body of the lambda, and prefix all unused variables.

The workaround is to prefix the unused variables with _:

[{Idx,I} || Idx, {req, _FF} <- [{req, [10,20,30]}], I <- _FF]
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

No branches or pull requests

1 participant