diff options
| author | gingerBill <ginger.bill.22@gmail.com> | 2016-08-17 12:04:17 +0100 |
|---|---|---|
| committer | gingerBill <ginger.bill.22@gmail.com> | 2016-08-17 12:04:17 +0100 |
| commit | c4fe2ace0595ae51f620aaada1807295e41cd6b5 (patch) | |
| tree | 98f9c7dfc4d21e2e93687566a055deea4502bfa4 /src/checker | |
| parent | 511f3744f695d52330651b17f1e3ef49c56b7c76 (diff) | |
Fix Scoping of proc type decls
Diffstat (limited to 'src/checker')
| -rw-r--r-- | src/checker/checker.cpp | 8 | ||||
| -rw-r--r-- | src/checker/expr.cpp | 3 | ||||
| -rw-r--r-- | src/checker/stmt.cpp | 1 |
3 files changed, 3 insertions, 9 deletions
diff --git a/src/checker/checker.cpp b/src/checker/checker.cpp index 1bc50a890..e75da4c87 100644 --- a/src/checker/checker.cpp +++ b/src/checker/checker.cpp @@ -101,7 +101,6 @@ struct Scope { Scope *prev, *next; Scope *first_child, *last_child; Map<Entity *> elements; // Key: String - gbArray(AstNode *) deferred_stmts; }; enum ExpressionKind { @@ -196,7 +195,6 @@ Scope *make_scope(Scope *parent, gbAllocator allocator) { Scope *s = gb_alloc_item(allocator, Scope); s->parent = parent; map_init(&s->elements, gb_heap_allocator()); - gb_array_init(s->deferred_stmts, gb_heap_allocator()); if (parent != NULL && parent != universal_scope) { DLIST_APPEND(parent->first_child, parent->last_child, s); } @@ -513,12 +511,6 @@ void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *dec gb_array_append(c->procs, info); } -void check_add_deferred_stmt(Checker *c, AstNode *stmt) { - GB_ASSERT(stmt != NULL); - GB_ASSERT(is_ast_node_stmt(stmt)); - gb_array_append(c->context.scope->deferred_stmts, stmt); -} - void push_procedure(Checker *c, Type *type) { gb_array_append(c->proc_stack, type); } diff --git a/src/checker/expr.cpp b/src/checker/expr.cpp index 8f017df80..c74d9e332 100644 --- a/src/checker/expr.cpp +++ b/src/checker/expr.cpp @@ -409,7 +409,10 @@ Type *check_type(Checker *c, AstNode *e, Type *named_type) { case_ast_node(pt, ProcType, e); type = alloc_type(c->allocator, Type_Proc); set_base_type(named_type, type); + CheckerContext context = c->context; + c->context.scope = make_scope(c->context.scope, c->allocator); check_procedure_type(c, type, e); + c->context = context; goto end; case_end; diff --git a/src/checker/stmt.cpp b/src/checker/stmt.cpp index 0ae500efc..95d25616e 100644 --- a/src/checker/stmt.cpp +++ b/src/checker/stmt.cpp @@ -737,7 +737,6 @@ void check_stmt(Checker *c, AstNode *node, u32 flags) { c->in_defer = true; check_stmt(c, ds->stmt, 0); c->in_defer = out_in_defer; - check_add_deferred_stmt(c, ds->stmt); } case_end; |