diff options
-rw-r--r-- | cgen.c | 9 | ||||
-rw-r--r-- | out.c | 2 | ||||
-rw-r--r-- | parse.c | 1 | ||||
-rw-r--r-- | test.toc | 2 |
4 files changed, 9 insertions, 5 deletions
@@ -108,11 +108,16 @@ static bool cgen_decl(CGenerator *g, Declaration *d) { /* because , is left-associative, we want to go backwards */ arr_foreach_reverse(&d->idents, Identifier, ident) { Type *type; - if (d->type.kind == TYPE_TUPLE) { + if (d->idents.len > 1) { /* it's a tuple! */ type = &(((Type*)d->type.tuple.data)[--i]); } else { type = &d->type; + if (type->kind == TYPE_TUPLE) { + /* TODO */ + err_print(d->where, "Direct declaration of tuples is not supported yet."); + return false; + } } cgen_type_pre(g, type); if (d->flags & DECL_FLAG_CONST) { /* TODO: remove this */ @@ -127,7 +132,7 @@ static bool cgen_decl(CGenerator *g, Declaration *d) { if (d->flags & DECL_FLAG_HAS_EXPR) { cgen_write_space(g); - if (d->type.kind == TYPE_TUPLE) { + if (d->idents.len > 1) { if (expr->kind == EXPR_BINARY_OP && expr->binary.op == BINARY_COMMA) { if (!cgen_expr(g, expr->binary.rhs)) return false; expr = expr->binary.lhs; /* ((3,4),5),6 => (3,4),5 */ @@ -2,7 +2,7 @@ /* toc */ void main__(void) { - int64_t salkdfj = 123; float something = 6.320000; int64_t baz = 5; int64_t bar = 4; int64_t foo = 3; + int64_t salkdfj = 0; float something = 0; int64_t baz = 0; int64_t bar = 0; int64_t foo = 0; } int main(void) { @@ -968,7 +968,6 @@ static bool parse_single_type_in_decl(Parser *p, Declaration *d) { tokr_err(t, "You must specify either all types or no types in a single declaration."); return false; } - printf("%lu\n",n_idents_with_this_type); if (annotates_type) { d->flags |= DECL_FLAG_ANNOTATES_TYPE; Type type; @@ -1,3 +1,3 @@ main @= fn() { - foo, bar, baz : int, something : float, salkdfj : int = 3, 4, 5, 6.32, 123; + foo, bar, baz : int, something : float, salkdfj : int; }; |