diff --git a/lib/std/core/builtin.c3 b/lib/std/core/builtin.c3 index 983ff8dee..c0a517aa4 100644 --- a/lib/std/core/builtin.c3 +++ b/lib/std/core/builtin.c3 @@ -362,6 +362,7 @@ macro uint bool.hash(bool b) => (uint)b; macro uint typeid.hash(typeid t) => ((ulong)(uptr)t).hash(); macro uint String.hash(String c) => (uint)fnv32a::encode(c); macro uint char[].hash(char[] c) => (uint)fnv32a::encode(c); +macro uint void*.hash(void* ptr) => ((ulong)(uptr)ptr).hash(); module std::core::builtin @if((env::LINUX || env::DARWIN) && env::COMPILER_SAFE_MODE && env::DEBUG_SYMBOLS); import libc; diff --git a/lib/std/core/dstring.c3 b/lib/std/core/dstring.c3 index 29926dfaa..385b58965 100644 --- a/lib/std/core/dstring.c3 +++ b/lib/std/core/dstring.c3 @@ -282,10 +282,10 @@ macro void DString.append(&self, value) self.append_char32(value); $default: $switch - $case $assignable(value, Char32): - self.append_char32(value); - $case $assignable(value, String): - self.append_chars(value); + $case $defined((Char32)value): + self.append_char32((Char32)value); + $case $defined((String)value): + self.append_chars((String)value); $default: $error "Unsupported type for append – use printf instead."; $endswitch diff --git a/lib/std/io/stream.c3 b/lib/std/io/stream.c3 index fad348f1a..2dae7c115 100644 --- a/lib/std/io/stream.c3 +++ b/lib/std/io/stream.c3 @@ -136,7 +136,7 @@ macro usz! print_gen(self, x) $case DString: return self.write(x.str_view()); $default: - $if $assignable(x, String): + $if $defined((String)x): return self.write((String)x); $else return printf("%s", x); diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index f2b6f0cc7..d46449575 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -2945,10 +2945,7 @@ static bool sema_analyse_macro_method(SemaContext *context, Decl *decl) Type *parent_type = parent_type_info->type; if (!type_may_have_method(parent_type)) { - SEMA_ERROR(parent_type_info, - "Methods can not be associated with '%s'", - type_to_error_string(parent_type)); - return false; + RETURN_SEMA_ERROR(parent_type_info, "Methods can not be associated with '%s'", type_to_error_string(parent_type)); } if (!vec_size(decl->func_decl.signature.params)) { diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 9482c9cdb..78902acb6 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -3984,8 +3984,7 @@ static inline bool sema_expr_analyse_access(SemaContext *context, Expr *expr, bo // 7. Is this a pointer? If so we insert a deref. Type *underlying_type = type_no_optional(parent->type)->canonical; - bool is_pointer = underlying_type->type_kind == TYPE_POINTER; - if (is_pointer) + if (underlying_type->type_kind == TYPE_POINTER && underlying_type != type_voidptr) { if (!sema_cast_rvalue(context, parent)) return false; expr_rewrite_insert_deref(expr->access_expr.parent); diff --git a/src/compiler/types.c b/src/compiler/types.c index 4302b7eda..3e9987ec9 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -1879,9 +1879,10 @@ bool type_may_have_method(Type *type) return true; case TYPE_TYPEDEF: UNREACHABLE + case TYPE_POINTER: + return type == type_voidptr; case TYPE_POISONED: case TYPE_VOID: - case TYPE_POINTER: case TYPE_FUNC: case TYPE_UNTYPED_LIST: case TYPE_OPTIONAL: diff --git a/src/version.h b/src/version.h index 35105b19c..ec4728678 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.689" +#define COMPILER_VERSION "0.4.690"