From 6ebb3caa20edda7d1f76c41b89a30d6e3ce17aa1 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 27 Aug 2023 19:04:34 +0200 Subject: [PATCH] Fix issue where type wasn't canonical. Addresses #957 --- lib/std/collections/object.c3 | 7 +++++++ src/compiler/sema_expr.c | 2 +- src/version.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/std/collections/object.c3 b/lib/std/collections/object.c3 index 380fee9c3..1c6efdea6 100644 --- a/lib/std/collections/object.c3 +++ b/lib/std/collections/object.c3 @@ -310,6 +310,10 @@ fn void Object.set_object_at(&self, usz index, Object* to_set) self.array.set_at(index, to_set); } +/** + * @require $Type.kindof.is_int() "Expected an integer type." + * @checked ($Type)1.0 "Expected an integer type." + **/ macro get_integer_value(Object* value, $Type) { if (value.is_float()) @@ -328,8 +332,10 @@ macro get_integer_value(Object* value, $Type) return ($Type)value.i; } + /** * @require self.is_indexable() + * @require $Type.kindof.is_int() : "Expected an integer type" **/ macro Object.get_integer_at(&self, $Type, usz index) @private { @@ -338,6 +344,7 @@ macro Object.get_integer_at(&self, $Type, usz index) @private /** * @require self.is_keyable() + * @require $Type.kindof.is_int() : "Expected an integer type" **/ macro Object.get_integer(&self, $Type, String key) @private { diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index a573dc48a..61c1a405b 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -3064,7 +3064,7 @@ static inline bool sema_expr_analyse_member_access(SemaContext *context, Expr *e return true; case TYPE_PROPERTY_KINDOF: case TYPE_PROPERTY_SIZEOF: - return sema_expr_rewrite_to_type_property(context, expr, decl->type, type_property, decl->type); + return sema_expr_rewrite_to_type_property(context, expr, decl->type->canonical, type_property, decl->type->canonical); case TYPE_PROPERTY_ELEMENTS: case TYPE_PROPERTY_EXTNAMEOF: case TYPE_PROPERTY_PARAMS: diff --git a/src/version.h b/src/version.h index ed56b266f..d26206ff7 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.620" \ No newline at end of file +#define COMPILER_VERSION "0.4.621" \ No newline at end of file