mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 14:48:47 +00:00
Only check idents in the alias (of alias)+ problem
This commit is contained in:
+1
-1
@@ -385,7 +385,7 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init,
|
|||||||
Operand operand = {};
|
Operand operand = {};
|
||||||
|
|
||||||
if (init != nullptr) {
|
if (init != nullptr) {
|
||||||
Entity *entity = check_entity_from_ident_or_selector(ctx, init);
|
Entity *entity = check_entity_from_ident_or_selector(ctx, init, false);
|
||||||
if (entity != nullptr && entity->kind == Entity_TypeName) {
|
if (entity != nullptr && entity->kind == Entity_TypeName) {
|
||||||
// @TypeAliasingProblem
|
// @TypeAliasingProblem
|
||||||
// NOTE(bill, 2022-02-03): This is used to solve the problem caused by type aliases
|
// NOTE(bill, 2022-02-03): This is used to solve the problem caused by type aliases
|
||||||
|
|||||||
+2
-2
@@ -4082,11 +4082,11 @@ bool is_entity_declared_for_selector(Entity *entity, Scope *import_scope, bool *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(bill, 2022-02-03): see `check_const_decl` for why it exists reasoning
|
// NOTE(bill, 2022-02-03): see `check_const_decl` for why it exists reasoning
|
||||||
Entity *check_entity_from_ident_or_selector(CheckerContext *c, Ast *node) {
|
Entity *check_entity_from_ident_or_selector(CheckerContext *c, Ast *node, bool ident_only) {
|
||||||
if (node->kind == Ast_Ident) {
|
if (node->kind == Ast_Ident) {
|
||||||
String name = node->Ident.token.string;
|
String name = node->Ident.token.string;
|
||||||
return scope_lookup(c->scope, name);
|
return scope_lookup(c->scope, name);
|
||||||
} else if (node->kind == Ast_SelectorExpr) {
|
} else if (!ident_only) if (node->kind == Ast_SelectorExpr) {
|
||||||
ast_node(se, SelectorExpr, node);
|
ast_node(se, SelectorExpr, node);
|
||||||
if (se->token.kind == Token_ArrowRight) {
|
if (se->token.kind == Token_ArrowRight) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
+1
-1
@@ -3670,7 +3670,7 @@ bool correct_single_type_alias(CheckerContext *c, Entity *e) {
|
|||||||
DeclInfo *d = e->decl_info;
|
DeclInfo *d = e->decl_info;
|
||||||
if (d != nullptr && d->init_expr != nullptr) {
|
if (d != nullptr && d->init_expr != nullptr) {
|
||||||
Ast *init = d->init_expr;
|
Ast *init = d->init_expr;
|
||||||
Entity *alias_of = check_entity_from_ident_or_selector(c, init);
|
Entity *alias_of = check_entity_from_ident_or_selector(c, init, true);
|
||||||
if (alias_of != nullptr && alias_of->kind == Entity_TypeName) {
|
if (alias_of != nullptr && alias_of->kind == Entity_TypeName) {
|
||||||
e->kind = Entity_TypeName;
|
e->kind = Entity_TypeName;
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user