Core: Fix array counting

This commit is contained in:
Krzosa Karol
2023-04-21 09:36:33 +02:00
parent 9edb03e1bb
commit ef243724dc
3 changed files with 5 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ call "..\misc\compile_setup.bat"
bld --dont_compile_core
cd build
core_main.exe rtsgame/main.core
rem core_main.exe rtsgame/main.core
bld --dont_compile_core --link=vendor/raylib/windows/raylibdll.lib
rem build\generated_main.exe
cd ..

View File

@@ -47,7 +47,7 @@ Add(&guys, {100, 100})
// @reproduction
// MAP: [16*16]int = {0, 1}
//
//
// This generates: int MAP[256] = (int [256]){[0] = 0, [0] = 1}; it doesn't work because of the (int[256]) is this MSVC being retarded here? not supporting C properly?
// Also this ^ ^
@@ -87,6 +87,7 @@ MouseSelectedActors: Array(*MAP.Actor) // @todo: ids
main :: (): int
MAP.Init()
// HERE_IT_IS: [16*16]int = {0, 1}
// InitAudioDevice()
// sound := LoadSound("catune - Pass the town, and to the C.mp3")

View File

@@ -1040,7 +1040,7 @@ resolve_compound_array(Ast_Call *node, Ast_Type *type) {
if (is_array(type) && node->exprs.len > size)
compiler_error(node->pos, "Too many items in compound expression, expected: %lld got: %lld", size, node->exprs.len);
S64 default_counter = 0;
int default_counter = 0;
For(node->exprs) {
if (is_flag_set(it->call_flags, CALL_NAME))
compiler_error(it->pos, "Arrays can't have named compound expression arguments");
@@ -1064,6 +1064,7 @@ resolve_compound_array(Ast_Call *node, Ast_Type *type) {
make_sure_value_is_compatible_with_type(it->pos, &item, item_type, TYPE_AND_EXPR_REQUIRED);
it->resolved_type = item_type;
try_propagating_resolved_type_to_untyped_literals(it->item, it->resolved_type);
default_counter += 1;
}
}