D6837: Fix bug 381123: crash while parsing PHP code

Matthijs Tijink noreply at phabricator.kde.org
Sat Jul 22 17:49:11 UTC 2017


mtijink created this revision.
mtijink added a project: KDevelop.
Restricted Application added a subscriber: kdevelop-devel.

REVISION SUMMARY
  In bug 381123 KDevelop crashed on certain PHP code. The underlying cause seems to that the `classDec` does not have an `internalContext()` set (no clue why, I couldn't figure that out).
  
  This diff fixes the crash, but does not yield the desired behaviour: automatically deriving the type of the foreach variable (i.e. in the example of the test plan: the `$row` variable should be an `int`, but is currently calculated as `mixed`. Placing the foreach after the class definition works, though).

TEST PLAN
  The following steps used to crash kdevelop, now they don't.
  
  1. Open the following file and wait until it's been parsed (reduced from the example of Alexander Zighalin as posted on bug 381123)
  
    <?php
    /*
    
    /* */
    foreach(new foo() as $row) {}
    
    class foo implements Iterator {
        public function current(): int {
        }
    }
  
  2. Close the comment on line 2 by hitting enter and closing it with `*/`

REPOSITORY
  R52 KDevelop: PHP Support

REVISION DETAIL
  https://phabricator.kde.org/D6837

AFFECTED FILES
  duchain/builders/typebuilder.cpp

To: mtijink, #kdevelop
Cc: kdevelop-devel, #kdevelop, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170722/3729b31c/attachment.html>


More information about the KDevelop-devel mailing list