diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-30 21:11:29 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2019-11-30 21:11:29 -0500 |
commit | d984e1585b749f184d2014ffff498ce5f36bcf5a (patch) | |
tree | 0dd29e1f6f52dd42d70255ec89513b124f3f16a8 | |
parent | d24409b9bf4783be63109f59d8558cef884069e6 (diff) |
fixed was_expr bug
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | parse.c | 1 | ||||
-rw-r--r-- | test.toc | 31 | ||||
-rw-r--r-- | types.c | 2 |
4 files changed, 21 insertions, 15 deletions
@@ -1,6 +1,6 @@ /* TODO: -functions returning Types +fix VBS with structs test ArrInt @= Arr(int); packages @@ -945,6 +945,7 @@ static int op_precedence(Keyword op) { static bool parse_expr(Parser *p, Expression *e, Token *end) { Tokenizer *t = p->tokr; e->flags = 0; + e->type.flags = 0; if (end == NULL) return false; e->where = t->token->where; if (end <= t->token) { @@ -1,11 +1,11 @@ -// puti @= fn(x: int) { -// #C("printf(\"%ld\\n\", (long)x); -// "); -// }; -// putf @= fn(x: float) { -// #C("printf(\"%f\\n\", (double)x); -// "); -// }; +puti @= fn(x: int) { + #C("printf(\"%ld\\n\", (long)x); +"); +}; +putf @= fn(x: float) { + #C("printf(\"%f\\n\", (double)x); +"); +}; // f @= fn(x @ int) Type { // struct { @@ -15,13 +15,16 @@ -f @= fn(s @ Type) Type { -t @= int; -t +pair @= fn(s @ Type) Type { + [2]s }; main @= fn() { -x : f(int); -y : f(int); -z : f(float); +x : pair(int); +y : pair(int); +z : pair(float); +x[0] = 7; +puti(x[0]); +z[0] = 3.3; +putf(z[0]); };
\ No newline at end of file @@ -495,6 +495,7 @@ static bool type_resolve(Typer *tr, Type *t, Location where) { if (!eval_expr(tr->evalr, t->expr, &typeval)) return false; *t = *typeval.type; + assert(t->flags & TYPE_IS_RESOLVED); } break; case TYPE_UNKNOWN: case TYPE_VOID: @@ -726,6 +727,7 @@ static bool types_expr(Typer *tr, Expression *e) { t->kind = TYPE_SLICE; t->slice = typer_malloc(tr, sizeof *t->slice); t->slice->flags = TYPE_IS_RESOLVED; + t->slice->was_expr = NULL; t->slice->kind = TYPE_BUILTIN; t->slice->builtin = BUILTIN_CHAR; t->flags |= TYPE_IS_RESOLVED; |