fix: bug in Any2String

This commit is contained in:
2023-11-09 18:17:20 +08:00
parent 5ad5615586
commit 9b8b23e738
4 changed files with 28 additions and 19 deletions

View File

@ -52,7 +52,7 @@ std::any FucntionContainer::CallFunction(
if (name == "print") {
bool is_first = true;
for (int i = 0; i < args.size(); i++) {
if (is_first) std::cout << ' ';
if (!is_first) std::cout << ' ';
is_first = false;
std::string buf = Any2String(args[i].value);
std::cout << buf;
@ -125,10 +125,13 @@ std::any FucntionContainer::CallFunction(
std::any res = vis.visit(func.code_address);
Variables.DestroyFrame();
FlowType *flow = std::any_cast<FlowType>(&res);
if(!flow)
{
if(flow->ReturnValueLists.size()==1) return flow->ReturnValueLists[0];
else return flow->ReturnValueLists;
if (!flow) {
if (flow->ReturnValueLists.size() == 0)
return NoneType();
else if (flow->ReturnValueLists.size() == 1)
return flow->ReturnValueLists[0];
else
return flow->ReturnValueLists;
}
return NoneType();
}