mirror of https://github.com/exaloop/codon.git
Fix corner case when typechecking scoped names with static compilation (#392)
* Fix corner case when typechecking scoped names with static compilation * Undo log --------- Co-authored-by: Ibrahim Numanagić <ibrahimpasa@gmail.com>pull/396/head
parent
38e08b409a
commit
2b2f6498b2
|
@ -372,6 +372,10 @@ void TranslateVisitor::visit(AssignStmt *stmt) {
|
|||
auto isGlobal = in(ctx->cache->globals, var);
|
||||
ir::Var *v = nullptr;
|
||||
|
||||
// dead declaration due to static compilation
|
||||
if (!stmt->rhs && !stmt->type && !stmt->lhs->type->getClass())
|
||||
return;
|
||||
|
||||
if (isGlobal) {
|
||||
seqassert(ctx->find(var) && ctx->find(var)->getVar(), "cannot find global '{}'",
|
||||
var);
|
||||
|
|
|
@ -64,7 +64,7 @@ void TypecheckVisitor::visit(AssignStmt *stmt) {
|
|||
ctx->instantiate(stmt->type->getSrcInfo(), stmt->type->getType()));
|
||||
}
|
||||
ctx->add(TypecheckItem::Var, lhs, stmt->lhs->type);
|
||||
if (realize(stmt->lhs->type))
|
||||
if (realize(stmt->lhs->type) || !stmt->type)
|
||||
stmt->setDone();
|
||||
} else if (stmt->type && stmt->type->getType()->isStaticType()) {
|
||||
// Static assignments (e.g., `x: Static[int] = 5`)
|
||||
|
|
|
@ -7,6 +7,11 @@ class __internal__:
|
|||
class __magic__:
|
||||
pass
|
||||
|
||||
@tuple
|
||||
@__internal__
|
||||
class NoneType:
|
||||
pass
|
||||
|
||||
@tuple
|
||||
@__internal__
|
||||
@__notuple__
|
||||
|
@ -40,11 +45,6 @@ class float32:
|
|||
MIN_10_EXP = -37
|
||||
pass
|
||||
|
||||
@tuple
|
||||
@__internal__
|
||||
class NoneType:
|
||||
pass
|
||||
|
||||
@tuple
|
||||
@__internal__
|
||||
class type:
|
||||
|
|
Loading…
Reference in New Issue