Bug 488885

Summary: Assertion in ExpressionVisitor::visitListComprehension when parsing complex expression
Product: [Developer tools] kdev-python Reporter: frmdstryr <frmdstryr>
Component: Language supportAssignee: Sven Brauch <mail>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Neon   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description frmdstryr 2024-06-21 11:34:06 UTC
SUMMARY

I kept seeing a crash and traced it down to when kdevelop parses the file at https://github.com/horizon-eda/horizon/blob/master/scripts/pybis.py . It hits the assertion at https://invent.kde.org/kdevelop/kdev-python/-/blob/master/duchain/expressionvisitor.cpp?ref_type=heads#L478 

STEPS TO REPRODUCE

The failing comprehension code is at https://github.com/horizon-eda/horizon/blob/master/scripts/pybis.py#L1672-L1676. I copied it here:

```
        stub_desc = (
            stubKeyword('Len') +"
            Each([ Optional(stubKeyword(k)) for k in [ 'L', 'R', 'C' ] ]) -
            Suppress(Literal('/') + LineEnd() * (0,)) 
        ).setParseAction(lambda f: IBISNode(f.asDict()))
```

OBSERVED RESULT

The assertion that the context is found fails.

EXPECTED RESULT

It should probably just ignore determining the list type when no context is found? Wrapping that code in an `if(comprehensionContext) {` avoids the problem.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:  6.0
KDE Plasma Version:  6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.0

ADDITIONAL INFORMATION

I'm using the KF6 branches for KDevelop and the kdev-python but that should not matter.