Bug 292170

Summary: Type collection from ternary operation broken
Product: [Developer tools] kdev-python Reporter: Eike Hein <hein>
Component: generalAssignee: kdevelop-bugs-null
Status: RESOLVED FIXED    
Severity: normal CC: mail
Priority: NOR    
Version: git master   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Eike Hein 2012-01-22 09:20:52 UTC
Given:

def foo(bar):
    x = 1 if bar else 2.0
    return x

... kdev-python will show the type of x as float, and accordingly the return type of foo as well. Yet it should be unsure(int, float).
Comment 1 Sven Brauch 2012-01-22 10:43:52 UTC
Git commit d3f52a0d60a39470b18caa0c2c7d8bb482fd058d by Sven Brauch.
Committed on 22/01/2012 at 11:42.
Pushed by brauch into branch 'master'.

implement type support for ternary operators

foo = 3 if False else "str" # <- foo:unsure(int,str)

M  +1    -0    documentation_files/builtindocumentation.py
M  +16   -0    duchain/expressionvisitor.cpp
M  +1    -0    duchain/expressionvisitor.h

http://commits.kde.org/kdev-python/d3f52a0d60a39470b18caa0c2c7d8bb482fd058d
Comment 2 Eike Hein 2012-01-22 10:53:47 UTC
Thanks, fix confirmed :).