修复定义变量未提供值时内存泄漏的bug。修复lexer解析字符串不能多行的bug

This commit is contained in:
2026-02-09 14:25:15 +08:00
parent 966b6eb805
commit e98beb03d7
2 changed files with 17 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
#include "Ast/Statements/InterfaceDefSt.hpp"
#include <Ast/Statements/InterfaceDefSt.hpp>
#include <Evaluator/Core/ExprResult.hpp>
#include <Ast/AccessModifier.hpp>
#include <Ast/Expressions/FunctionCall.hpp>
@@ -65,6 +65,10 @@ namespace Fig
value = std::make_shared<Object>(Object::defaultValue(declaredType));
} // else -> Ok
} // else -> type is Any (default)
else
{
value = Object::getNullInstance();
}
AccessModifier am =
(varDef->isConst ? (varDef->isPublic ? AccessModifier::PublicConst : AccessModifier::Const) :
(varDef->isPublic ? AccessModifier::Public : AccessModifier::Normal));
@@ -185,31 +189,23 @@ namespace Fig
ObjectPtr itf_val = check_unwrap_stres(eval(exp, ctx));
if (!itf_val->is<InterfaceType>())
{
throw EvaluatorError(
u8"TypeError",
std::format(
"Cannot bundle type '{}' that is not interface",
prettyType(itf_val).toBasicString()
),
exp
);
throw EvaluatorError(u8"TypeError",
std::format("Cannot bundle type '{}' that is not interface",
prettyType(itf_val).toBasicString()),
exp);
}
const InterfaceType &itfType = itf_val->as<InterfaceType>();
for (const auto &method : itfType.methods)
{
if (cache_methods.contains(method.name))
{
throw EvaluatorError(
u8"DuplicateInterfaceMethodError",
std::format(
"Interface `{}` has duplicate method '{}' with '{}.{}'",
throw EvaluatorError(u8"DuplicateInterfaceMethodError",
std::format("Interface `{}` has duplicate method '{}' with '{}.{}'",
itfType.type.toString().toBasicString(),
method.name.toBasicString(),
cache_methods[method.name].toBasicString(),
method.name.toBasicString()
),
ifd
);
method.name.toBasicString()),
ifd);
}
cache_methods[method.name] = itfType.type.toString();
bundle_methods.push_back(method);

View File

@@ -162,7 +162,7 @@ namespace Fig
while (hasNext())
{
UTF8Char c = *it;
if (c == U'"' || c == U'\n')
if (c == U'"')
{
next();
unterminated = false;