<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 06/06/2013 01:47 AM, Anthony Ramine wrote:
<blockquote
cite="mid:D24EA20D-0BCF-49B3-BF96-03D3C29DDB06@gmail.com"
type="cite">
<pre wrap="">Hello,
When analyzing complex expressions (i.e. comprehensions, cases, tries, ifs and receives), erl_lint does not forget about old unused variables when returning the updated variable table. This causes a bug where old
unused variables are not recorded as such:
t(X, Y) ->
#r{a=[ K || K <- Y ],b=[ K || K <- Y ].
As erl_lint uses vtmerge_pat/2 to merge the results of the analysis of the two list comprehensions, X is marked as used and the warning is not emitted.
The function vtmerge_pat/2 is used instead of the similar vtmerge/2 which does not mark multiple occurrences of a variable as usage to handle cases like the following one:
t(X, Y) ->
#r{a=A=X,b=A=Y}.
Other simpler expressions like conses, tuples and external fun references does not correctly follow this behaviour.
This patch fixes both issues and makes erl_lint not return old unused variables in updated tables and makes all compound expressions use vtmerge_pat/2.
git fetch <a class="moz-txt-link-freetext" href="https://github.com/nox/otp.git">https://github.com/nox/otp.git</a> fix-erl_lint-variable-usage
<a class="moz-txt-link-freetext" href="https://github.com/nox/otp/compare/erlang:maint...fix-erl_lint-variable-usage">https://github.com/nox/otp/compare/erlang:maint...fix-erl_lint-variable-usage</a>
<a class="moz-txt-link-freetext" href="https://github.com/nox/otp/compare/erlang:maint...fix-erl_lint-variable-usage.patch">https://github.com/nox/otp/compare/erlang:maint...fix-erl_lint-variable-usage.patch</a>
Regards,
</pre>
</blockquote>
Hi Anthony,<br>
Your patch has been reviewed and the feedback was:<br>
<br>
"
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 9px;
margin-left: 0px; font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; font-size: 13px; line-height: 18px; color: rgb(51, 51,
51); font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; orphans: 2; text-align:
-webkit-auto; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust:
auto; -webkit-text-stroke-width: 0px; background-color: rgb(249,
249, 249); ">Hi,</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 9px;
margin-left: 0px; font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; font-size: 13px; line-height: 18px; color: rgb(51, 51,
51); font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; orphans: 2; text-align:
-webkit-auto; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust:
auto; -webkit-text-stroke-width: 0px; background-color: rgb(249,
249, 249); ">The first example of the commit messages lacks a '}'
before the dot.</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 9px;
margin-left: 0px; font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; font-size: 13px; line-height: 18px; color: rgb(51, 51,
51); font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; orphans: 2; text-align:
-webkit-auto; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust:
auto; -webkit-text-stroke-width: 0px; background-color: rgb(249,
249, 249); ">I'm not sure I understand exactly what the paragraph
starting with "Other simpler expressions..." means. Could you
clarify, please? (And substitute "do" for "does"...)</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 9px;
margin-left: 0px; font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; font-size: 13px; line-height: 18px; color: rgb(51, 51,
51); font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; orphans: 2; text-align:
-webkit-auto; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust:
auto; -webkit-text-stroke-width: 0px; background-color: rgb(249,
249, 249); ">I noticed that if the call to vt_no_unused() in the
last line of expr_list/3 is removed the test suite still passes;
there is no case where the call actually removes anything. Would
it be possible to include a test that covers this particular call?</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 9px;
margin-left: 0px; font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; font-size: 13px; line-height: 18px; color: rgb(51, 51,
51); font-style: normal; font-variant: normal; font-weight:
normal; letter-spacing: normal; orphans: 2; text-align:
-webkit-auto; text-indent: 0px; text-transform: none; white-space:
normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust:
auto; -webkit-text-stroke-width: 0px; background-color: rgb(249,
249, 249); ">Best regards,</p>
"<br>
<br>
<pre class="moz-signature" cols="72">--
BR Fredrik Gustafsson
Erlang OTP Team</pre>
</body>
</html>