Fix call tests [wip]

typecheck-v2
Ibrahim Numanagić 2023-12-04 21:28:35 -08:00
parent 32b2af6b1b
commit abadfeb03e
2 changed files with 10 additions and 0 deletions

View File

@ -434,6 +434,14 @@ void TranslateVisitor::visit(AssignStmt *stmt) {
seqassert(stmt->lhs->getId(), "expected IdExpr, got {}", stmt->lhs);
auto var = stmt->lhs->getId()->value;
if (!stmt->rhs || (!stmt->rhs->isType() && stmt->rhs->type)) {
if (stmt->rhs && stmt->rhs->type->getFunc())
return;
if (stmt->rhs && stmt->rhs->type->getPartial() &&
!ctx->find(stmt->rhs->type->getClass()->realizedTypeName())) {
// Partial generic; ignore [TODO]
return;
}
auto isGlobal = in(ctx->cache->globals, var);
ir::Var *v = nullptr;

View File

@ -150,6 +150,8 @@ StmtPtr TypecheckVisitor::transformAssignment(AssignStmt *stmt, bool mustExist)
unify(assign->lhs->type, assign->rhs->type);
if (stmt->rhs->isType())
val->type = val->type->getClass();
else if (stmt->rhs->type->getFunc())
val->type = val->type->getFunc();
auto type = assign->lhs->getType();
// Generalize non-variable types. That way we can support cases like:
// `a = foo(x, ...); a(1); a('s')`