Bug 488885 - Assertion in ExpressionVisitor::visitListComprehension when parsing complex expression
Summary: Assertion in ExpressionVisitor::visitListComprehension when parsing complex e...
Status: REPORTED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Language support (show other bugs)
Version: unspecified
Platform: Neon Linux
: NOR normal
Target Milestone: ---
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-21 11:34 UTC by frmdstryr
Modified: 2024-06-21 11:34 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.