Bug 296709

Summary: incorrect coloring and tooltip of foreach ... as variable
Product: [Applications] kdevelop Reporter: Jakob Lund <jakob.bugs>
Component: Language Support: PHPAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 4.3.0   
Target Milestone: 4.3.0   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In:

Description Jakob Lund 2012-03-24 20:50:20 UTC
In this code

  foreach ($new_users as $newuser) {
      $newuser['pass'] = f();
  }

the highlighter seems to miss the fact that the two occurences of $newuser refer to the same varible. The second occurence is rendered in bold, and when the cursor hovers, only the second is highlighted, and the tooltip refers to that line as the source of the variable declaration.

The expected behavoiur would be to highlight both, and refer to the first occurence as the point of definition.
Comment 1 Milian Wolff 2012-03-29 17:36:55 UTC
Git commit 75493103a0b53ddc364b229020ffde216ea7d7cb by Milian Wolff.
Committed on 29/03/2012 at 19:35.
Pushed by mwolff into branch '1.3'.

take range into account when looking for redeclarations

probably we should refactor the handling of foreach
variables, since right now we have to visit the
TypeBuilder::visitStatement before declaring the variables.
this has side-effects since it also means we visit the
foreach-body statements before declaring the variables...

M  +2    -1    duchain/builders/declarationbuilder.cpp
M  +43   -0    duchain/tests/duchain.cpp
M  +1    -0    duchain/tests/duchain.h

http://commits.kde.org/kdev-php/75493103a0b53ddc364b229020ffde216ea7d7cb