Browse Source

Correct map usage

gingerBill 1 year ago
parent
commit
4bea5dbac1
3 changed files with 3 additions and 3 deletions
  1. 1 1
      src/checker.cpp
  2. 1 1
      src/llvm_backend_general.cpp
  3. 1 1
      src/llvm_backend_type.cpp

+ 1 - 1
src/checker.cpp

@@ -2192,7 +2192,7 @@ gb_internal void add_min_dep_type_info(Checker *c, Type *t) {
 	// IMPORTANT NOTE(bill): this must be copied as `map_set` takes a const ref
 	// and effectively assigns the `+1` of the value
 	isize const count = set->count;
-	if (map_set_if_not_previously_exists(set, ti_index, count)) {
+	if (map_set_if_not_previously_exists(set, ti_index+1, count)) {
 		// Type already exists;
 		return;
 	}

+ 1 - 1
src/llvm_backend_general.cpp

@@ -140,7 +140,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
 	}
 
 	gen->default_module.gen = gen;
-	map_set(&gen->modules, cast(void *)nullptr, &gen->default_module);
+	map_set(&gen->modules, cast(void *)1, &gen->default_module);
 	lb_init_module(&gen->default_module, c);
 
 

+ 1 - 1
src/llvm_backend_type.cpp

@@ -2,7 +2,7 @@ gb_internal isize lb_type_info_index(CheckerInfo *info, Type *type, bool err_on_
 	auto *set = &info->minimum_dependency_type_info_set;
 	isize index = type_info_index(info, type, err_on_not_found);
 	if (index >= 0) {
-		auto *found = map_get(set, index);
+		auto *found = map_get(set, index+1);
 		if (found) {
 			GB_ASSERT(*found >= 0);
 			return *found + 1;