diff --git a/duchain/expressionvisitor.cpp b/duchain/expressionvisitor.cpp --- a/duchain/expressionvisitor.cpp +++ b/duchain/expressionvisitor.cpp @@ -395,7 +395,13 @@ if ( type ) { foreach ( ExpressionAst* content, node->elements ) { contentVisitor.visitNode(content); - type->addContentType(contentVisitor.lastType()); + if ( content->astType == Ast::StarredAstType ) { + auto contentType = Helper::contentOfIterable(contentVisitor.lastType(), topContext()); + type->addContentType(contentType); + } + else { + type->addContentType(contentVisitor.lastType()); + } } } else { @@ -519,7 +525,13 @@ if ( type ) { foreach ( ExpressionAst* content, node->elements ) { contentVisitor.visitNode(content); - type->addContentType(contentVisitor.lastType()); + if ( content->astType == Ast::StarredAstType ) { + auto contentType = Helper::contentOfIterable(contentVisitor.lastType(), topContext()); + type->addContentType(contentType); + } + else { + type->addContentType(contentVisitor.lastType()); + } } } encounter(AbstractType::Ptr::staticCast(type)); diff --git a/duchain/tests/pyduchaintest.cpp b/duchain/tests/pyduchaintest.cpp --- a/duchain/tests/pyduchaintest.cpp +++ b/duchain/tests/pyduchaintest.cpp @@ -1474,12 +1474,14 @@ QTest::addColumn("code"); QTest::addColumn("contenttype"); QTest::addColumn("use_type"); - + QTest::newRow("list_of_int") << "checkme = [1, 2, 3]" << "int" << false; + QTest::newRow("list_from_unpacked") << "foo = [1.3]\ncheckme = [1, *foo, 3]" << "unsure (int, float)" << false; QTest::newRow("list_of_int_call") << "checkme = list([1, 2, 3])" << "int" << false; QTest::newRow("generator") << "checkme = [i for i in [1, 2, 3]]" << "int" << false; QTest::newRow("list_access") << "list = [1, 2, 3]\ncheckme = list[0]" << "int" << true; QTest::newRow("set_of_int") << "checkme = {1, 2, 3}" << "int" << false; + QTest::newRow("set_from_unpacked") << "foo = [1.3]\ncheckme = {1, *foo, 3}" << "unsure (int, float)" << false; QTest::newRow("set_of_int_call") << "checkme = set({1, 2, 3})" << "int" << false; QTest::newRow("set_generator") << "checkme = {i for i in [1, 2, 3]}" << "int" << false; QTest::newRow("dict_of_int") << "checkme = {a:1, b:2, c:3}" << "int" << false;