<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://git.reviewboard.kde.org/r/117551/">https://git.reviewboard.kde.org/r/117551/</a>
     </td>
    </tr>
   </table>
   <br />





<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
 <p style="margin-top: 0;">On April 22nd, 2014, 9:37 p.m. UTC, <b>Sven Brauch</b> wrote:</p>
 <blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
  <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">By the way, does qmljs do more than one parse pass? I think that's required to deal with function foo(a) { return a; }; foo(3) or so ...
Did you try what happens when you do that? If it doesn't work, submit this anyways, that can be fixed later.</pre>
 </blockquote>







</blockquote>

<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">The parser currently performs only one parsing pass, and a function whose return type depends on the type of a parameter is currently not correctly recognized (your example declares foo as "mixed foo(int)"). This could be fixed by parsing the file several times (two times should allow most cases to work, but some Javascript libraries use deeply nested functions and call statements). Another possibility would be to find the AST node corresponding to the function whose parameters have been updated, and to re-visit it. This might lead to infinite loops or slow parsing, though.</pre>
<br />










<p>- Denis</p>


<br />
<p>On April 23rd, 2014, 4:48 p.m. UTC, Denis Steckelmacher wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://git.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for KDevelop.</div>
<div>By Denis Steckelmacher.</div>


<p style="color: grey;"><i>Updated April 23, 2014, 4:48 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
kdev-qmljs
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">When a function is called, the type of the parameters passed to it is used to update the type of the function (as seen from the outside, for instance "function void (string)") and the type of its parameters as seen from the inside (the declaration of "param1" of type "string").

The changes of this patch are limited to DeclarationBuilder (plus a unit test), but the code is fairly complex because it has to ensure that the proper number of arguments are being passed to the function (if it is not the case, then these arguments should not be used to update the function's type). Moreover, the type of the function must be entirely re-created, as FunctionType has no way of modifying the type if the arguments once it has been created (there is an arguments() method, but modifying the types there doesn't change the FunctionType itself).</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">An unit test has been added. It checks that the types are correctly deduced and that DeclarationBuilder doesn't crash on malformed input.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>tests/files/helloworld.js <span style="color: grey">(a746b48)</span></li>

 <li>duchain/declarationbuilder.h <span style="color: grey">(395ab75)</span></li>

 <li>duchain/declarationbuilder.cpp <span style="color: grey">(55ad2e0)</span></li>

</ul>

<p><a href="https://git.reviewboard.kde.org/r/117551/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>