Browse Source

Fix `make` error messages

gingerBill 7 years ago
parent
commit
877a78d6ba
4 changed files with 8 additions and 7 deletions
  1. 1 1
      core/mem/alloc.odin
  2. 1 1
      core/os/os_windows.odin
  3. 4 4
      core/runtime/internal.odin
  4. 2 1
      src/ir.cpp

+ 1 - 1
core/mem/alloc.odin

@@ -120,7 +120,7 @@ make_dynamic_array :: proc(T: type/[dynamic]$E, len, cap: int, loc := #caller_lo
 	return transmute(T)s;
 }
 make_map :: proc(T: type/map[$K]$E, cap: int = 16, loc := #caller_location) -> T {
-	runtime.make_map_array_error_loc(loc, cap);
+	runtime.make_map_expr_error_loc(loc, cap);
 	m: T;
 	reserve_map(&m, cap);
 	return m;

+ 1 - 1
core/os/os_windows.odin

@@ -273,7 +273,7 @@ _alloc_command_line_arguments :: proc() -> []string {
 		olen := win32.wide_char_to_multi_byte(win32.CP_UTF8, 0, wc_str, -1,
 		                                      nil, 0, nil, nil);
 
-		buf := make([]byte, olen);
+		buf := make([]byte, int(olen));
 		n := win32.wide_char_to_multi_byte(win32.CP_UTF8, 0, wc_str, -1,
 		                                   cstring(&buf[0]), olen, nil, nil);
 		if n > 0 {

+ 4 - 4
core/runtime/internal.odin

@@ -325,7 +325,7 @@ dynamic_array_expr_error_loc :: inline proc "contextless" (using loc := #caller_
 
 
 make_slice_error_loc :: inline proc "contextless" (using loc := #caller_location, len: int) {
-	if 0 < len do return;
+	if 0 <= len do return;
 
 	fd := os.stderr;
 	__print_caller_location(fd, loc);
@@ -336,7 +336,7 @@ make_slice_error_loc :: inline proc "contextless" (using loc := #caller_location
 }
 
 make_dynamic_array_error_loc :: inline proc "contextless" (using loc := #caller_location, len, cap: int) {
-	if 0 < len && len < cap do return;
+	if 0 <= len && len <= cap do return;
 
 	fd := os.stderr;
 	__print_caller_location(fd, loc);
@@ -348,8 +348,8 @@ make_dynamic_array_error_loc :: inline proc "contextless" (using loc := #caller_
 	debug_trap();
 }
 
-map_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, cap: int) {
-	if 0 < cap do return;
+make_map_expr_error_loc :: inline proc "contextless" (using loc := #caller_location, cap: int) {
+	if 0 <= cap do return;
 
 	fd := os.stderr;
 	__print_caller_location(fd, loc);

+ 2 - 1
src/ir.cpp

@@ -7244,7 +7244,8 @@ void ir_begin_procedure_body(irProcedure *proc) {
 		e->flags |= EntityFlag_NoAlias;
 		irValue *param = ir_value_param(proc, e, e->type);
 		ir_module_add_value(proc->module, e, param);
-		array_add(&proc->context_stack, {param, proc->scope_index});
+		irContextData ctx = {param, proc->scope_index};
+		array_add(&proc->context_stack, ctx);
 	}
 }