fix: bug of loss dequate

This commit is contained in:
2023-11-09 20:02:52 +08:00
parent 12ffce995b
commit 6ae4d56a03
3 changed files with 3 additions and 2 deletions

View File

@ -184,6 +184,7 @@ std::any EvalVisitor::visitContinue_stmt(
std::any EvalVisitor::visitReturn_stmt(Python3Parser::Return_stmtContext *ctx) {
if (!ctx->testlist()) return FlowType(RETURN, std::vector<std::any>());
std::any val = visitTestlist(ctx->testlist());
val = DeQuate(val, Variables);
std::vector<std::any> *val_ptr = std::any_cast<std::vector<std::any>>(&val);
if (val_ptr) return FlowType(RETURN, *val_ptr);
std::vector<std::any> tmp;

View File

@ -15,7 +15,7 @@ std::any VariableContainer::ReadVariable(const std::string &name) {
if (top.find(name) != top.end()) return top[name];
}
if (GlobalScope.find(name) != GlobalScope.end()) return GlobalScope[name];
throw InterpretException(("ReadVariable: " + name + " not found").c_str());
throw InterpretException(("ReadVariable: not found"));
}
void VariableContainer::WriteVariable(const std::string &name,
const std::any &value, bool cover) {