Fix bug 381123: crash while parsing PHP code

Authored by mtijink on Jul 26 2017, 12:41 PM.

Description

Fix bug 381123: crash while parsing PHP code

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 {
    }
}
  1. Close the comment on line 2 by hitting enter and closing it with */

Reviewers: KDevelop, zhigalin

Subscribers: mwolff, zhigalin, apol, kfunk, kdevelop-devel, KDevelop

Tags: KDevelop

Differential Revision: https://phabricator.kde.org/D6837

Details

Committed
zhigalinJul 26 2017, 4:29 PM
Differential Revision
D6837: Fix bug 381123: crash while parsing PHP code
Parents
R52:9bdc7781abbc: SVN_SILENT made messages (.desktop file) - always resolve ours
Branches
Unknown
Tags
Unknown