diff options
| author | gingerBill <ginger.bill.22@gmail.com> | 2016-07-08 01:04:57 +0100 |
|---|---|---|
| committer | gingerBill <ginger.bill.22@gmail.com> | 2016-07-08 01:04:57 +0100 |
| commit | 9ba2a6d02cab3feff9d70f7bb9c2e8eb72bc5533 (patch) | |
| tree | 4c4536db506feafcec7157e4064268ffce5a931f /src/checker/statements.cpp | |
| parent | 7430008fd7088339821923bdff533369b7967904 (diff) | |
Slices and slice expressions
Diffstat (limited to 'src/checker/statements.cpp')
| -rw-r--r-- | src/checker/statements.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/checker/statements.cpp b/src/checker/statements.cpp index 036b096c9..15a0904a6 100644 --- a/src/checker/statements.cpp +++ b/src/checker/statements.cpp @@ -38,8 +38,14 @@ b32 check_assignable_to(Checker *c, Operand *operand, Type *type) { if (sb->kind == Type_Array && tb->kind == Type_Array) { if (are_types_identical(sb->array.element, tb->array.element)) { - if (tb->array.count == 0) // NOTE(bill): Not static size - return true; + return sb->array.count == tb->array.count; + } + } + + if ((sb->kind == Type_Array || sb->kind == Type_Slice) && + tb->kind == Type_Slice) { + if (are_types_identical(sb->array.element, tb->slice.element)) { + return true; } } @@ -233,7 +239,7 @@ void check_init_variables(Checker *c, Entity **lhs, isize lhs_count, AstNode *in if (i < lhs_count) { if (lhs[i]->type == NULL) print_checker_error(c, lhs[i]->token, "Too few values on the right hand side of the declaration"); - } else if (rhs != NULL) { + } else if (rhs != NULL) { print_checker_error(c, ast_node_token(rhs), "Too many values on the right hand side of the declaration"); } } |