aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-08-05 17:23:50 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2024-08-05 17:23:50 +0200
commit6175efde3d4b2ec2cdac172cce0f2d1887705af2 (patch)
treee9bfcfe0d3c8c492ca976abe5e88d9a5e96546ae
parent030220eb229c5cb56d222bd21ae90936a3d1ad3d (diff)
Fix crash if referencing import "aliased" in other file.
Fixes #4026
-rw-r--r--src/check_expr.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index b291cbe70..4bce42129 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -5158,6 +5158,14 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
Scope *import_scope = e->ImportName.scope;
String entity_name = selector->Ident.token.string;
+ if (import_scope == nullptr) {
+ ERROR_BLOCK();
+ error(node, "'%.*s' is not imported in this file, '%.*s' is unavailable", LIT(import_name), LIT(entity_name));
+ operand->mode = Addressing_Invalid;
+ operand->expr = node;
+ return nullptr;
+ }
+
check_op_expr = false;
entity = scope_lookup_current(import_scope, entity_name);
bool allow_builtin = false;