diff options
-rw-r--r-- | eval.c | 2 | ||||
-rw-r--r-- | test.toc | 2 | ||||
-rw-r--r-- | types.c | 3 | ||||
-rw-r--r-- | types.h | 4 |
4 files changed, 9 insertions, 2 deletions
@@ -1,4 +1,5 @@ static bool types_block(Typer *tr, Block *b); +static bool types_decl(Typer *tr, Declaration *d); static size_t compiler_sizeof(Type *t); static bool eval_block(Evaluator *ev, Block *b, Type *t, Value *v); static bool eval_expr(Evaluator *ev, Expression *e, Value *v); @@ -1010,6 +1011,7 @@ static bool eval_expr(Evaluator *ev, Expression *e, Value *v) { case EXPR_IDENT: { IdentDecl *idecl = ident_decl(e->ident); Declaration *d = idecl->decl; + if (!types_decl(ev->typer, d)) return false; if (idecl->flags & IDECL_FLAG_HAS_VAL) { *v = idecl->val; } else if (d->flags & DECL_FLAG_CONST) { @@ -7,6 +7,8 @@ Point @= struct { x, y : int; }; + + sum @= fn(p: &Point) int { p.x + p.y }; @@ -1164,6 +1164,8 @@ static bool types_expr(Typer *tr, Expression *e) { } static bool types_block(Typer *tr, Block *b) { + if (b->flags & BLOCK_FLAG_FOUND_TYPES) + return true; bool success = true; Block *prev_block = tr->block; tr->block = b; @@ -1182,6 +1184,7 @@ static bool types_block(Typer *tr, Block *b) { } block_exit(b, b->stmts); tr->block = prev_block; + b->flags |= BLOCK_FLAG_FOUND_TYPES; return success; } @@ -310,9 +310,9 @@ typedef struct Type { } Type; #define BLOCK_FLAG_FN 0x01 - +#define BLOCK_FLAG_FOUND_TYPES 0x02 typedef struct Block { - uint16_t flags; + U16 flags; Location start; Location end; struct Statement *stmts; |