From 12813e5d48a3bb0976abfdf63ffe7fbfa2f37aed Mon Sep 17 00:00:00 2001 From: FourteenBrush <74827262+FourteenBrush@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:37:40 +0200 Subject: [PATCH] Fix 'odin [run|test] --' giving a compiler out of bounds --- src/main.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 41a95338b..77758b929 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2973,13 +2973,19 @@ int main(int arg_count, char const **arg_ptr) { break; } } - if(run_args_start_idx != -1) { + if (run_args_start_idx != -1) { last_non_run_arg = run_args_start_idx; + + if (run_args_start_idx == 2) { + // missing src path on argv[2], invocation: odin [run|test] -- + usage(args[0]); + return 1; + } + for(isize i = run_args_start_idx+1; i < args.count; ++i) { array_add(&run_args, args[i]); } } - args = array_slice(args, 0, last_non_run_arg); run_args_string = string_join_and_quote(heap_allocator(), run_args);