Skip to content

Commit

Permalink
fix custom operators not working with namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Spydr06 committed Oct 17, 2024
1 parent f7e1494 commit 9b3ad71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/compiler/parser/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,7 @@ static ASTNode_T* parse_custom_prefix_operator(Parser_T* p)
ASTNode_T* call = init_ast_node(&p->context->raw_allocator, ND_CALL, p->tok);
call->expr = init_ast_node(&p->context->raw_allocator, ND_ID, p->tok);
call->expr->id = init_ast_identifier(&p->context->raw_allocator, p->tok, p->tok->value);
call->expr->id->global_scope = false;

parser_consume(p, TOKEN_OPERATOR, "expect operator");

Expand Down
6 changes: 4 additions & 2 deletions src/compiler/parser/validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,13 @@ static ASTObj_T* scope_contains(Scope_T* scope, const char* id)

static IdentResolveResult_T scope_resolve_ident(Validator_T* v, Scope_T* scope, ASTIdentifier_T* ident)
{
if(ident->global_scope)
scope = v->global_scope;

if(!scope || !ident)
return IDENT_MISSING(ident);

if(ident->global_scope)
scope = v->global_scope;

if(ident->outer)
{
IdentResolveResult_T outer_result = scope_resolve_ident(v, scope, ident->outer);
Expand Down

0 comments on commit 9b3ad71

Please sign in to comment.