mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
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>
This commit is contained in:
parent
38e08b409a
commit
2b2f6498b2
@ -372,6 +372,10 @@ void TranslateVisitor::visit(AssignStmt *stmt) {
|
|||||||
auto isGlobal = in(ctx->cache->globals, var);
|
auto isGlobal = in(ctx->cache->globals, var);
|
||||||
ir::Var *v = nullptr;
|
ir::Var *v = nullptr;
|
||||||
|
|
||||||
|
// dead declaration due to static compilation
|
||||||
|
if (!stmt->rhs && !stmt->type && !stmt->lhs->type->getClass())
|
||||||
|
return;
|
||||||
|
|
||||||
if (isGlobal) {
|
if (isGlobal) {
|
||||||
seqassert(ctx->find(var) && ctx->find(var)->getVar(), "cannot find global '{}'",
|
seqassert(ctx->find(var) && ctx->find(var)->getVar(), "cannot find global '{}'",
|
||||||
var);
|
var);
|
||||||
|
@ -64,7 +64,7 @@ void TypecheckVisitor::visit(AssignStmt *stmt) {
|
|||||||
ctx->instantiate(stmt->type->getSrcInfo(), stmt->type->getType()));
|
ctx->instantiate(stmt->type->getSrcInfo(), stmt->type->getType()));
|
||||||
}
|
}
|
||||||
ctx->add(TypecheckItem::Var, lhs, stmt->lhs->type);
|
ctx->add(TypecheckItem::Var, lhs, stmt->lhs->type);
|
||||||
if (realize(stmt->lhs->type))
|
if (realize(stmt->lhs->type) || !stmt->type)
|
||||||
stmt->setDone();
|
stmt->setDone();
|
||||||
} else if (stmt->type && stmt->type->getType()->isStaticType()) {
|
} else if (stmt->type && stmt->type->getType()->isStaticType()) {
|
||||||
// Static assignments (e.g., `x: Static[int] = 5`)
|
// Static assignments (e.g., `x: Static[int] = 5`)
|
||||||
|
@ -7,6 +7,11 @@ class __internal__:
|
|||||||
class __magic__:
|
class __magic__:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@tuple
|
||||||
|
@__internal__
|
||||||
|
class NoneType:
|
||||||
|
pass
|
||||||
|
|
||||||
@tuple
|
@tuple
|
||||||
@__internal__
|
@__internal__
|
||||||
@__notuple__
|
@__notuple__
|
||||||
@ -40,11 +45,6 @@ class float32:
|
|||||||
MIN_10_EXP = -37
|
MIN_10_EXP = -37
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@tuple
|
|
||||||
@__internal__
|
|
||||||
class NoneType:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@tuple
|
@tuple
|
||||||
@__internal__
|
@__internal__
|
||||||
class type:
|
class type:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user