Closed agladilin closed 2 years ago
The code below is parsed incorrectly
class Base { public: Base(std::vector<int> columns) {} }; class Derived { public: Derived() : Base(std::vector<int>{1, 2, 3}) {} };
The std::vector<int>{1, 2, 3} is parsed as a function call.
std::vector<int>{1, 2, 3}
(gdb) p *memInit.second { <CppObj> = {_vptr.CppObj = 0x5555556028c0 <vtable for CppExpr+16>, objType_ = CppObjType::kExpression, accessType_ = CppAccessType::kUnknown, owner_ = 0x0}, static kObjectType = CppObjType::kExpression, expr1_ = { {atom = 0x5555556760d0, expr = 0x5555556760d0, lambda = 0x5555556760d0, varType = 0x5555556760d0}, type = CppExprAtom::kExpr }, expr2_ = { {atom = 0x555555676050, expr = 0x555555676050, lambda = 0x555555676050, varType = 0x555555676050}, type = CppExprAtom::kExpr }, expr3_ = { {atom = 0x0, expr = 0x0, lambda = 0x0, varType = 0x0}, type = CppExprAtom::kExpr }, oper_ = kFunctionCall, flags_ = 0 }
Therefore, once we use a CppWriter, the result is the following:
Derived() : Base(std::vector<int>(1, 2, 3)) { }
Its a bug, I will look into it and fix it soon. Thanks for reporting and giving a detailed analysis.
This should now be fixed with commit 97458486. Please use the latest CppParser.
It works now. Thanks a lot!
The code below is parsed incorrectly
The
std::vector<int>{1, 2, 3}
is parsed as a function call.Therefore, once we use a CppWriter, the result is the following: