Summary: | KDevelop PHP parsing crash after adding "if " inside a class method | ||
---|---|---|---|
Product: | [Applications] kdevelop | Reporter: | unix1 |
Component: | general | Assignee: | kdevelop-bugs-null |
Status: | RESOLVED FIXED | ||
Severity: | crash | CC: | unix1 |
Priority: | NOR | ||
Version: | 4.1.60 | ||
Target Milestone: | 4.2.0 | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
unix1
2011-01-14 02:59:04 UTC
I reproduced the crash without having to enter "if " - so it seems like a more generic crash and not specific to that keyword. commit d5f65c1f80d1e58e9a981a5a849438b68c57a07d branch 1.2 Author: Milian Wolff <mail@milianw.de> Date: Fri Jan 14 10:40:36 2011 +0100 prevent crash in ExpressionVisitor::visitEncapsVar when class is currentClass and hence internalContext is not yet set BUG: 263095 diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp index a122db3..85c17a4 100644 --- a/duchain/expressionvisitor.cpp +++ b/duchain/expressionvisitor.cpp @@ -483,10 +483,20 @@ void ExpressionVisitor::visitEncapsVar(EncapsVarAst *node) DUChainReadLocker lock(DUChain::lock()); if ( StructureType::Ptr structType = dec->type<StructureType>() ) { if ( ClassDeclaration* cdec = dynamic_cast<ClassDeclaration*>(structType->declaration(m_currentContext->topContext())) ) { - foreach( Declaration* pdec, cdec->internalContext()->findDeclarations(identifierForNode(node->propertyIdentifier)) ) { - if ( !pdec->isFunctionDeclaration() ) { - foundDec = pdec; - break; + ///TODO: share code with visitVariableProperty + DUContext* ctx = cdec->internalContext(); + if (!ctx && m_currentContext->parentContext()) { + if (m_currentContext->parentContext()->localScopeIdentifier() == cdec->qualifiedIdentifier()) { + //class is currentClass (internalContext is not yet set) + ctx = m_currentContext->parentContext(); + } + } + if (ctx) { + foreach( Declaration* pdec, ctx->findDeclarations(identifierForNode(node->propertyIdentifier)) ) { + if ( !pdec->isFunctionDeclaration() ) { + foundDec = pdec; + break; + } } } } |