fix: bug in Div

This commit is contained in:
2023-11-10 16:18:13 +08:00
parent d4473c5f78
commit 98d3b40369

View File

@ -210,8 +210,7 @@ std::any Mul(std::any a, std::any b) {
std::string *ptr_b_string = std::any_cast<std::string>(&b);
if ((ptr_a_string != nullptr ? 1 : 0) + (ptr_b_string != nullptr ? 1 : 0) ==
2) {
throw InterpretException(
"Mul: string operation not allowed in this situation", 40);
return std::string("");
} else if ((ptr_a_string != nullptr ? 1 : 0) +
(ptr_b_string != nullptr ? 1 : 0) ==
1) {
@ -273,9 +272,9 @@ std::any Div(std::any a, std::any b) {
"Div: string operation not allowed in this situation", 43);
double t_a = Any2Float(a);
double t_b = Any2Float(b);
if (t_b == 0) throw InterpretException("Div: divided by zero", 44);
// if (t_b == 0) throw InterpretException("Div: divided by zero", 44);
t_a = t_a / t_b;
return a;
return t_a;
}
std::any Divv(std::any a, std::any b) {
if (std::any_cast<NoneType>(&a)) a = (bool)false;