Slices and slice expressions

This commit is contained in:
gingerBill
2016-07-08 01:04:57 +01:00
parent 7430008fd7
commit 9ba2a6d02c
8 changed files with 327 additions and 48 deletions

View File

@@ -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");
}
}