Fixed bad error message when no return value + compound inferred type

This commit is contained in:
Krzosa Karol
2023-03-29 08:03:43 +02:00
parent 0804a76f7e
commit 67b966cb5b
3 changed files with 15 additions and 8 deletions

View File

@@ -50,7 +50,6 @@ Future features
- [ ] Way to import and force evaluate #import_lazy #import ? - [ ] Way to import and force evaluate #import_lazy #import ?
Redesign: Redesign:
- [ ] Redesign Type map to use List and reduce wasting space
- [ ] Casting syntax - [ ] Casting syntax
In the future In the future

View File

@@ -1466,7 +1466,7 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_and_const_str
} }
if (!type) if (!type)
type = compound_and_const_string_context; type = compound_and_const_string_context;
if (!type) if (type == pctx->type_void || type == nullptr)
compiler_error(node->pos, "Couldn't infer type of compound expression"); compiler_error(node->pos, "Couldn't infer type of compound expression");
type_complete(type); type_complete(type);

View File

@@ -1,15 +1,23 @@
#import "Arena.core" MA :: #import "Arena.core"
// @todo: /*
// Add new special type #Type_Size PushStruct :: (a: *MA.Arena, $Type): *Type
size := size_of(Type)
result := PushSize(a, size)
return result
*/
PushStruct :: (a: *Arena, type: Type /*#Type_Size*/): *void Color :: struct ;; r: F32; g: F32; b: F32; a: F32
AlmostLinearToSRGB :: (a: Color): Color;; return {asd(a.r), asd(a.g), asd(a.b), a.a}
PushStruct :: (a: *MA.Arena, type: Type): *void
ti := GetTypeInfo(type) ti := GetTypeInfo(type)
result := PushSize(a, ti.size->Base.SizeU) result := MA.PushSize(a, ti.size->U64)
return result return result
main :: (argc: int, argv: **char): int main :: (argc: int, argv: **char): int
arena: Arena arena: MA.Arena
a: *int = PushStruct(&arena, int) a: *int = PushStruct(&arena, int)
Assert(arena.len == SizeOf(int))
return 0 return 0