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

Compiler warning when using a variable bound in assert_receive #2798

Closed
alco opened this issue Oct 3, 2014 · 4 comments
Closed

Compiler warning when using a variable bound in assert_receive #2798

alco opened this issue Oct 3, 2014 · 4 comments
Milestone

Comments

@alco
Copy link
Member

alco commented Oct 3, 2014

The following code causes the compiler to emit a warning:

assert_receive {:ok, num}  # line 10
assert ^num = 13           # line 11
test/exunit_export_test.exs:11: warning: variable num@1 exported from 'receive' (line 10)

Example repo with 2 tags: warning and no-warninghttps://github.com/alco/ex_unit-warning-exported-var

@alco alco added the App:ExUnit label Oct 3, 2014
@DefiPanda
Copy link
Contributor

Interesting, I am running the latest code on master branch and didn't receive any warning when running mix test on your linked mix project.

@alco
Copy link
Member Author

alco commented Oct 7, 2014

@jw2013 you need to check out the warning tag.

@DefiPanda
Copy link
Contributor

@alco Ah, thanks so much for the clarification.

Is there any particular reason we don't use this instead:

num = 13                          # line 10
assert_receive {:ok, ^num}        # line 11

@josevalim josevalim modified the milestone: v1.0.3 Jan 5, 2015
@lexmag
Copy link
Member

lexmag commented Jan 16, 2015

It happens beyond assert_receive example with every macro + export_head before ^, e.g:

destructure([x], [3])
^x = 3

and comes from erl_lint.erl.

josevalim pushed a commit that referenced this issue Jan 28, 2015
Closes #2798

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants