diff options
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | parse.c | 13 | ||||
-rw-r--r-- | test.toc | 3 | ||||
-rw-r--r-- | types.c | 2 |
4 files changed, 17 insertions, 3 deletions
@@ -1,7 +1,5 @@ /* TODO: -structs -structs can't have tuple members dot length of slice/arr with .len verify size of struct, align of fields @@ -479,6 +479,15 @@ static bool parse_type(Parser *p, Type *type) { if (!parse_decl(p, &field_decl, DECL_END_SEMICOLON, 0)) { return false; } + if (field_decl.flags & DECL_FLAG_CONST) { + /* TODO */ + err_print(field_decl.where, "Constant struct members are not supported (yet)."); + return false; + } + if (field_decl.flags & DECL_FLAG_HAS_EXPR) { + err_print(field_decl.where, "struct members cannot have initializers."); + return false; + } long idx = 0; arr_foreach(field_decl.idents, Identifier, fident) { Type *ftype = field_decl.type.kind == TYPE_TUPLE ? &field_decl.type.tuple[idx] : &field_decl.type; @@ -1544,6 +1553,10 @@ static bool parse_decl(Parser *p, Declaration *d, DeclEndKind ends_with, uint16_ goto ret_false; } d->type = type; + if (type.kind == TYPE_TUPLE && arr_len(d->type.tuple) != arr_len(d->idents)) { + err_print(d->where, "Expected to have %lu things declared in declaration, but got %lu.", (unsigned long)arr_len(d->type.tuple), (unsigned long)arr_len(d->idents)); + goto ret_false; + } } const char *end_str = NULL; switch (ends_with) { @@ -6,8 +6,11 @@ puti @= fn(x: int) { Point @= struct { x, y : int; something:fn(f32); + z,asdfasdfasdf:(int,int); + safdasdjfhsj@int=3; }; main @= fn() { p:Point; + // asasdfdsfa:(int,int); }; @@ -1206,7 +1206,7 @@ static bool types_decl(Typer *tr, Declaration *d) { size_t n_idents = arr_len(d->idents); if (d->type.kind == TYPE_TUPLE) { if (n_idents != arr_len(d->type.tuple)) { - err_print(d->where, "Expected to have %lu things declared in declaration, but got %lu.", (unsigned long)n_idents); + err_print(d->where, "Expected to have %lu things declared in declaration, but got %lu.", (unsigned long)arr_len(d->type.tuple), (unsigned long)n_idents); success = false; goto ret; } |