From cfba19ab77f36b4566233b2f11f7a60e564814da Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 8 Mar 2023 00:13:38 +0100 Subject: [PATCH] Remove deprecated to avoid warnings for VarString. Fix issue casting subarrays to distinct types. --- lib/std/core/string.c3 | 4 ++-- src/compiler/sema_casts.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/std/core/string.c3 b/lib/std/core/string.c3 index 387a444d6..d12c5a2ad 100644 --- a/lib/std/core/string.c3 +++ b/lib/std/core/string.c3 @@ -9,7 +9,7 @@ typedef Text = VarString; const usz MIN_CAPACITY = 16; -fn VarString new_with_capacity(usz capacity, Allocator* allocator = mem::heap()) @deprecated +fn VarString new_with_capacity(usz capacity, Allocator* allocator = mem::heap()) { if (capacity < MIN_CAPACITY) capacity = MIN_CAPACITY; StringData* data = malloc(StringData, 1, .using = allocator, .end_padding = capacity); @@ -19,7 +19,7 @@ fn VarString new_with_capacity(usz capacity, Allocator* allocator = mem::heap()) return (VarString)data; } -fn VarString new(String c) @deprecated +fn VarString new(String c) { usz len = c.len; VarString str = new_with_capacity(len); diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index 4d8269fe7..fb122cd6d 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -1761,7 +1761,7 @@ static bool err_to_bool(Expr *expr, Type *to_type) return true; } -static inline bool subarray_to_bool(Expr *expr) +static inline bool subarray_to_bool(Expr *expr, Type *type) { if (expr->expr_kind == EXPR_CONST && expr->const_expr.const_kind == CONST_INITIALIZER) { @@ -1769,13 +1769,13 @@ static inline bool subarray_to_bool(Expr *expr) switch (list->kind) { case CONST_INIT_ZERO: - expr_rewrite_const_bool(expr, type_bool, false); + expr_rewrite_const_bool(expr, type, false); return true; case CONST_INIT_ARRAY: - expr_rewrite_const_bool(expr, type_bool, vec_size(list->init_array.elements) > 0); + expr_rewrite_const_bool(expr, type, vec_size(list->init_array.elements) > 0); return true; case CONST_INIT_ARRAY_FULL: - expr_rewrite_const_bool(expr, type_bool, vec_size(list->init_array_full) > 0); + expr_rewrite_const_bool(expr, type, vec_size(list->init_array_full) > 0); return true; case CONST_INIT_STRUCT: case CONST_INIT_UNION: @@ -1784,7 +1784,7 @@ static inline bool subarray_to_bool(Expr *expr) break; } } - return insert_cast(expr, CAST_SABOOL, type_bool); + return insert_cast(expr, CAST_SABOOL, type); } static bool cast_inner(Expr *expr, Type *from_type, Type *to, Type *to_type) @@ -1877,9 +1877,9 @@ static bool cast_inner(Expr *expr, Type *from_type, Type *to, Type *to_type) } // Starting in a little while... break; case TYPE_SUBARRAY: - if (to->type_kind == TYPE_POINTER) return insert_cast(expr, CAST_SAPTR, to); - if (to->type_kind == TYPE_BOOL) return subarray_to_bool(expr); - if (to->type_kind == TYPE_SUBARRAY) return subarray_to_subarray(expr, to); + if (to->type_kind == TYPE_POINTER) return insert_cast(expr, CAST_SAPTR, to_type); + if (to->type_kind == TYPE_BOOL) return subarray_to_bool(expr, to_type); + if (to->type_kind == TYPE_SUBARRAY) return subarray_to_subarray(expr, to_type); break; case TYPE_VECTOR: if (to->type_kind == TYPE_ARRAY) return vector_to_array(expr, to_type);