[Feat] 实现 std.formater库,增加 std.io.printf函数

[Fix] 修复 evaluator中处理else if condVal类型错误的低级问题
[Feat] 为 String类型增加 insert, replace, erase函数
This commit is contained in:
2025-12-29 18:27:39 +08:00
parent cd106fc513
commit 2a455a0487
6 changed files with 335 additions and 14 deletions

View File

@@ -1037,12 +1037,15 @@ namespace Fig
for (const auto &elif : ifSt->elifs)
{
ObjectPtr elifCondVal = eval(elif->condition, ctx);
throw EvaluatorError(
u8"TypeError",
std::format(
"Condition must be boolean, but got '{}'",
condVal->getTypeInfo().toString().toBasicString()),
ifSt->condition);
if (elifCondVal->getTypeInfo() != ValueType::Bool)
{
throw EvaluatorError(
u8"TypeError",
std::format(
"Condition must be boolean, but got '{}'",
condVal->getTypeInfo().toString().toBasicString()),
ifSt->condition);
}
if (elifCondVal->as<ValueType::BoolClass>())
{
return evalBlockStatement(elif->body, ctx);