summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-31 15:48:07 +0000
committerZuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian>2026-01-31 15:48:07 +0000
commitaced94a89dd732d8ae8fddd27de9e1f1094c449a (patch)
tree53ea0be7d9c39249ebe8d64ed06e2acc623748ba
parentccc53b11a0e273f46cb40e5f0eb32a74ab6750bf (diff)
Fix for #158
-rw-r--r--src/parser/parser_expr.c10
-rw-r--r--std/slice.zc4
2 files changed, 12 insertions, 2 deletions
diff --git a/src/parser/parser_expr.c b/src/parser/parser_expr.c
index 28dc465..7c53d96 100644
--- a/src/parser/parser_expr.c
+++ b/src/parser/parser_expr.c
@@ -5644,7 +5644,17 @@ ASTNode *parse_expr_prec(ParserContext *ctx, Lexer *l, Precedence min_prec)
char *t1 = type_to_string(lhs->type_info);
char *t2 = type_to_string(rhs->type_info);
// Skip type check if either operand is void* (escape hatch type)
+ // or if either operand is a generic type parameter (T, K, V, etc.)
int skip_check = (strcmp(t1, "void*") == 0 || strcmp(t2, "void*") == 0);
+ if (lhs->type_info->kind == TYPE_GENERIC || rhs->type_info->kind == TYPE_GENERIC)
+ {
+ skip_check = 1;
+ }
+ // Also check if type name is a single uppercase letter (common generic param)
+ if ((strlen(t1) == 1 && isupper(t1[0])) || (strlen(t2) == 1 && isupper(t2[0])))
+ {
+ skip_check = 1;
+ }
// Allow comparing pointers/strings with integer literal 0 (NULL)
if (!skip_check)
diff --git a/std/slice.zc b/std/slice.zc
index 3c317ca..c757fbd 100644
--- a/std/slice.zc
+++ b/std/slice.zc
@@ -28,8 +28,8 @@ impl SliceIter<T> {
}
impl Slice<T> {
- fn from_array(arr: T*, len: usize) -> Slice<T> {
- return Slice<T> { data: arr, len: len };
+ fn from_array(ptr: T*, len: usize) -> Slice<T> {
+ return Slice<T> { data: ptr, len: len };
}
// Alias for backwards compatibility with std/mem.zc