Compiler warning when using a variable bound in assert_receive
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-warning – https://github.com/alco/ex_unit-warning-exported-var
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.
@jw2013 you need to check out the warning tag.
@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
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.