diff options
| author | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-24 00:44:45 +0000 |
|---|---|---|
| committer | Zuhaitz Méndez Fernández de Aránguiz <zuhaitz@debian> | 2026-01-24 01:39:52 +0000 |
| commit | 769d8ff1a1fd898e1a8c8b299f7e7fa444f32528 (patch) | |
| tree | 8e8c19a3783b2d7633e09757d820ff180c825bd4 /src/parser/parser_type.c | |
| parent | f88dbd3140be8733ad464b669e0c9e977a4c3a13 (diff) | |
Relaxed strictness for type checking.
Diffstat (limited to 'src/parser/parser_type.c')
| -rw-r--r-- | src/parser/parser_type.c | 21 |
1 files changed, 21 insertions, 0 deletions
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); } |
