From 877a78d6ba2f31ac22278a780f6996eac18f02a4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 8 Aug 2018 23:07:51 +0100 Subject: [PATCH] Fix `make` error messages --- core/mem/alloc.odin | 2 +- core/os/os_windows.odin | 2 +- core/runtime/internal.odin | 8 ++++---- src/ir.cpp | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/core/mem/alloc.odin b/core/mem/alloc.odin index d610d35de..7d6da471e 100644 --- a/core/mem/alloc.odin +++ b/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; diff --git a/core/os/os_windows.odin b/core/os/os_windows.odin index 814cb2f4e..4c39bb59d 100644 --- a/core/os/os_windows.odin +++ b/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 { diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index c47fd16b4..34a6bf60f 100644 --- a/core/runtime/internal.odin +++ b/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); diff --git a/src/ir.cpp b/src/ir.cpp index fc7b42f7d..b351f8163 100644 --- a/src/ir.cpp +++ b/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); } }