From 769d8ff1a1fd898e1a8c8b299f7e7fa444f32528 Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Sat, 24 Jan 2026 00:44:45 +0000 Subject: Relaxed strictness for type checking. --- src/parser/parser_type.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/parser/parser_type.c') diff --git a/src/parser/parser_type.c b/src/parser/parser_type.c index 24e9f69..39a4dc7 100644 --- a/src/parser/parser_type.c +++ b/src/parser/parser_type.c @@ -439,6 +439,14 @@ Type *parse_type_base(ParserContext *ctx, Lexer *l) return type_new(TYPE_ISIZE); } + // Relaxed Type Check: If explicit 'struct Name', trust the user. + if (explicit_struct) + { + Type *ty = type_new(TYPE_STRUCT); + ty->name = name; + ty->is_explicit_struct = 1; + } + // Selective imports ONLY apply when we're NOT in a module context if (!ctx->current_module_prefix) { @@ -707,6 +715,19 @@ Type *parse_type_base(ParserContext *ctx, Lexer *l) return ty; } + // If we have an identifier that wasn't found, + // assume it is a valid external C type + // (for example, a struct defined in implementation). + if (t.type == TOK_IDENT) + { + char *fallback = token_strdup(t); + lexer_next(l); + Type *ty = type_new(TYPE_STRUCT); + ty->name = fallback; + ty->is_explicit_struct = 0; + return ty; + } + return type_new(TYPE_UNKNOWN); } -- cgit v1.2.3