aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-10-26 12:14:04 +0100
committergingerBill <bill@gingerbill.org>2019-10-26 12:14:04 +0100
commit94879ed14997c4d2745ddb669d08b34437ceff75 (patch)
tree6864270ffbfe71a53f3a295f496cf90cebf8121e /src
parent2c75fe2314aa6de6c8f80d519bbb1812ad77b444 (diff)
Fix Compiler assertion when applying `using` to `_` procedure parameter. #451
Diffstat (limited to 'src')
-rw-r--r--src/check_decl.cpp3
-rw-r--r--src/check_stmt.cpp7
-rw-r--r--src/entity.cpp3
-rw-r--r--src/ir.cpp4
4 files changed, 8 insertions, 9 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 5e8479a7f..ebfc29899 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -1167,11 +1167,10 @@ void check_proc_body(CheckerContext *ctx_, Token token, DeclInfo *decl, Type *ty
for_array(i, scope->elements.entries) {
Entity *f = scope->elements.entries[i].value;
if (f->kind == Entity_Variable) {
- Entity *uvar = alloc_entity_using_variable(e, f->token, f->type);
+ Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr);
uvar->Variable.is_immutable = is_immutable;
if (is_value) uvar->flags |= EntityFlag_Value;
-
ProcUsingVar puv = {e, uvar};
array_add(&using_entities, puv);
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index 26e3f8c26..72913903d 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -496,8 +496,7 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b
for_array(i, found->elements.entries) {
Entity *f = found->elements.entries[i].value;
if (f->kind == Entity_Variable) {
- Entity *uvar = alloc_entity_using_variable(e, f->token, f->type);
- uvar->using_expr = expr;
+ Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, expr);
Entity *prev = scope_insert(ctx->scope, uvar);
if (prev != nullptr) {
gbString expr_str = expr_to_string(expr);
@@ -2052,7 +2051,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
// TODO(bill): Should a 'continue' happen here?
}
- for (isize entity_index = 0; entity_index < entity_count; entity_index++) {
+ for (isize entity_index = 0; entity_index < 1; entity_index++) {
Entity *e = entities[entity_index];
if (e == nullptr) {
continue;
@@ -2071,7 +2070,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
for_array(i, scope->elements.entries) {
Entity *f = scope->elements.entries[i].value;
if (f->kind == Entity_Variable) {
- Entity *uvar = alloc_entity_using_variable(e, f->token, f->type);
+ Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, nullptr);
uvar->Variable.is_immutable = is_immutable;
Entity *prev = scope_insert(ctx->scope, uvar);
if (prev != nullptr) {
diff --git a/src/entity.cpp b/src/entity.cpp
index 78726171d..bbea68e8b 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -221,12 +221,13 @@ Entity *alloc_entity_variable(Scope *scope, Token token, Type *type, bool is_imm
return entity;
}
-Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type) {
+Entity *alloc_entity_using_variable(Entity *parent, Token token, Type *type, Ast *using_expr) {
GB_ASSERT(parent != nullptr);
token.pos = parent->token.pos;
Entity *entity = alloc_entity(Entity_Variable, parent->scope, token, type);
entity->using_parent = parent;
entity->parent_proc_decl = parent->parent_proc_decl;
+ entity->using_expr = using_expr;
entity->flags |= EntityFlag_Using;
entity->flags |= EntityFlag_Used;
entity->state = EntityState_Resolved;
diff --git a/src/ir.cpp b/src/ir.cpp
index bea9ee8b3..c654e2bf8 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -9743,7 +9743,7 @@ void ir_begin_procedure_body(irProcedure *proc) {
}
Type *abi_type = proc->type->Proc.abi_compat_params[i];
- if (e->token.string != "" && !is_blank_ident(e->token)) {
+ if (e->token.string != "") {
ir_add_param(proc, e, name, abi_type, parameter_index);
}
@@ -9766,7 +9766,7 @@ void ir_begin_procedure_body(irProcedure *proc) {
if (abi_types.count > 0) {
abi_type = abi_types[i];
}
- if (e->token.string != "" && !is_blank_ident(e->token)) {
+ if (e->token.string != "") {
ir_add_param(proc, e, nullptr, abi_type, parameter_index);
}
if (is_type_tuple(abi_type)) {