mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 11:20:08 +00:00
Enforce explicit context definition for procedure calls
This commit is contained in:
@@ -7411,6 +7411,12 @@ ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *call, Type *t
|
||||
|
||||
Type *pt = base_type(proc_type);
|
||||
|
||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
||||
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
|
||||
error(call, "'context' has not been defined within this scope, but is required for this procedure call");
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
|
||||
init_core_context(c->checker);
|
||||
|
||||
@@ -2512,6 +2512,8 @@ bool check_procedure_type(CheckerContext *ctx, Type *type, Ast *proc_type_node,
|
||||
GB_ASSERT(cc > 0);
|
||||
if (cc == ProcCC_Odin) {
|
||||
c->scope->flags |= ScopeFlag_ContextDefined;
|
||||
} else {
|
||||
c->scope->flags &= ~ScopeFlag_ContextDefined;
|
||||
}
|
||||
|
||||
bool variadic = false;
|
||||
|
||||
@@ -281,6 +281,7 @@ Scope *create_scope_from_package(CheckerContext *c, AstPackage *pkg) {
|
||||
if (s->flags & (ScopeFlag_Init|ScopeFlag_Global)) {
|
||||
s->flags |= ScopeFlag_HasBeenImported;
|
||||
}
|
||||
s->flags |= ScopeFlag_ContextDefined;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user