From 2745abda13f28c1ec02aae929d4118babe06df1d Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Mon, 19 Feb 2024 14:30:40 -0600 Subject: [PATCH] fixed: bug with `array.insert` --- CHANGELOG | 1 + compiler/src/lex.c | 2 +- core/container/array.onyx | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e12c7a86..273a6923 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -69,6 +69,7 @@ Contributors: - @jtakakura (1 pull request) - @hatappo (1 pull request) - @Syuparn (1 pull request) +- @benstt (1 pull request) Release v0.1.8 diff --git a/compiler/src/lex.c b/compiler/src/lex.c index 00459736..cc0e4d94 100644 --- a/compiler/src/lex.c +++ b/compiler/src/lex.c @@ -220,7 +220,7 @@ whitespace_skipped: tk.length = tokenizer->curr - tk.text - 2; - if (bh_arr_length(tokenizer->tokens) == 0 && bh_str_starts_with(tk.text, "+optional_semicolons")) { + if (bh_arr_length(tokenizer->tokens) == 0 && bh_str_starts_with(tk.text, "+optional-semicolons")) { tokenizer->optional_semicolons = 1; } diff --git a/core/container/array.onyx b/core/container/array.onyx index 95c476e7..17cb97b5 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -166,7 +166,7 @@ insert :: #match #local {} #overload insert :: (arr: &[..] $T, idx: u32, x: T) -> bool { - if idx >= arr.count do return false; + if idx > arr.count do return false; if !ensure_capacity(arr, arr.count + 1) do return false; arr.count += 1; @@ -181,7 +181,7 @@ insert :: (arr: &[..] $T, idx: u32, x: T) -> bool { #overload insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool { - if idx >= arr.count do return false; + if idx > arr.count do return false; if !ensure_capacity(arr, arr.count + new_arr.count) do return false; arr.count += new_arr.count; @@ -200,7 +200,7 @@ insert :: (arr: &[..] $T, idx: u32, new_arr: [] T) -> bool { Inserts a zeroed-element at `idx`. """ insert_empty :: (arr: &[..] $T, idx: u32) -> bool { - if idx >= arr.count do return false; + if idx > arr.count do return false; if !ensure_capacity(arr, arr.count + 1) do return false; arr.count += 1; -- 2.25.1