Fix import scoping

pull/117/head
Ibrahim Numanagić 2022-12-13 11:31:16 -08:00
parent ea390f7de9
commit 3e988f904d
2 changed files with 6 additions and 4 deletions

View File

@ -93,7 +93,8 @@ void SimplifyVisitor::visit(ImportStmt *stmt) {
LOG("-> fix {} :: {}", import.moduleName, i.first);
c = import.ctx->findDominatingBinding(i.first);
}
ctx->add(i.first, c);
// Imports should ignore noShadow property
ctx->Context<SimplifyItem>::add(i.first, c);
}
}
} else {
@ -106,7 +107,8 @@ void SimplifyVisitor::visit(ImportStmt *stmt) {
E(Error::IMPORT_NO_NAME, i, i->value, file->module);
if (c->isConditional())
c = import.ctx->findDominatingBinding(i->value);
ctx->add(stmt->as.empty() ? i->value : stmt->as, c);
// Imports should ignore noShadow property
ctx->Context<SimplifyItem>::add(stmt->as.empty() ? i->value : stmt->as, c);
}
if (!resultStmt) {

View File

@ -164,8 +164,8 @@ types::TypePtr TypecheckVisitor::realize(types::TypePtr typ) {
auto name = f->ast->name;
std::string name_args;
if (startswith(name, "._import_")) {
name = name.substr(10);
auto p = name.find('_');
name = name.substr(9);
auto p = name.rfind('_');
if (p != std::string::npos)
name = name.substr(0, p);
name = "<import " + name + ">";