Test fixes

typecheck-v2
Ibrahim Numanagić 2024-07-30 10:02:34 -07:00
parent 7382ae80a1
commit 1df21397b0
3 changed files with 6 additions and 4 deletions

View File

@ -74,7 +74,7 @@ ASTNode::ASTNode(const ASTNode &node) : Node(node), cache(node.cache) {}
Expr::Expr() : AcceptorExtend(), type(nullptr), done(false), origExpr(nullptr) {}
Expr::Expr(const Expr &expr)
: AcceptorExtend(expr), type(expr.type), done(expr.done), origExpr(expr.origExpr) {}
Expr::Expr(const Expr &expr, bool clean) : AcceptorExtend(expr) {
Expr::Expr(const Expr &expr, bool clean) : Expr(expr) {
if (clean) {
type = nullptr;
done = false;

View File

@ -183,7 +183,8 @@ std::string LinkType::debugString(char mode) const {
std::string LinkType::realizedName() const {
if (kind == Unbound)
return "?";
// return "?";
return fmt::format("#{}", genericName);
if (kind == Generic)
return fmt::format("#{}", genericName);
seqassert(kind == Link, "unexpected generic link");

View File

@ -371,15 +371,16 @@ types::TypePtr TypecheckVisitor::realizeFunc(types::FuncType *type, bool force)
auto pc = ast->getAttribute<ir::StringValueAttribute>(Attr::ParentClass);
if (!pc || pc->value.empty())
ctx->addFunc(ctx->cache->rev(ast->name), ast->name, ctx->find(ast->name)->type);
for (size_t i = 0, j = 0; hasAst && i < ast->args.size(); i++)
for (size_t i = 0, j = 0; hasAst && i < ast->args.size(); i++) {
if (ast->args[i].status == Param::Normal) {
std::string varName = ast->args[i].name;
trimStars(varName);
auto v = ctx->addVar(ctx->cache->rev(varName), varName,
std::make_shared<LinkType>(type->getArgTypes()[j++]));
// LOG("[param] {}| {}: {} -> {}", type->debugString(2), ctx->cache->rev(varName),
// v->canonicalName, v->type);
// v->canonicalName, v->type);
}
}
// Populate realization table in advance to support recursive realizations
auto key = type->realizedName(); // note: the key might change later