From 1949a37d701f5d4687c0fa2ca8c9be70882ef86e Mon Sep 17 00:00:00 2001 From: Fyodor <36414426+Unrealf1@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:35:32 +0300 Subject: [PATCH] Fix misleading error in some built in array functions Calling push with non-copyable argument caused "unused function argument" error, and not "can't push value, which can't be copied", while the latter was intended. This was because branch that actually uses the arguments was thrown away --- src/builtin/builtin.das | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/builtin/builtin.das b/src/builtin/builtin.das index d6480f087..f26f3836b 100644 --- a/src/builtin/builtin.das +++ b/src/builtin/builtin.das @@ -81,6 +81,7 @@ def resize_and_init(var Arr:array;newSize:int; initValue:numT) Arr[i] := initValue +[unused_argument(Arr, newSize)] def resize_no_init(var Arr:array;newSize:int) static_if typeinfo(is_raw type) static_if typeinfo(need_lock_check type) @@ -97,6 +98,7 @@ def reserve(var Arr:array;newSize:int) def pop(var Arr:array) unsafe(resize(Arr, length(Arr)-1)) // resize will throw if negative +[unused_argument(Arr, value)] def push(var Arr:array;value:numT-# const;at:int) static_if typeinfo(can_copy value) static_if typeinfo(need_lock_check type) @@ -105,6 +107,7 @@ def push(var Arr:array;value:numT-# const;at:int) else concept_assert(false,"can't push value, which can't be copied") +[unused_argument(Arr, value)] def push(var Arr:array;value:numT-# const) static_if typeinfo(can_copy value) static_if typeinfo(need_lock_check type) @@ -113,6 +116,7 @@ def push(var Arr:array;value:numT-# const) else concept_assert(false,"can't push value, which can't be copied") +[unused_argument(Arr, value)] def push(var Arr:array; varr:array-#) static_if typeinfo(can_copy type) static_if typeinfo(need_lock_check type) @@ -122,6 +126,7 @@ def push(var Arr:array; varr:array-#) else concept_assert(false,"can't push value, which can't be copied") +[unused_argument(Arr, value)] def push(var Arr:array; varr:numT[]-#) static_if typeinfo(can_copy type) static_if typeinfo(need_lock_check type) @@ -131,6 +136,7 @@ def push(var Arr:array; varr:numT[]-#) else concept_assert(false,"can't push value, which can't be copied") +[unused_argument(Arr, value)] def push(var Arr:array; varr:numT[]-#) static_if typeinfo(can_copy type) static_if typeinfo(sizeof Arr[0])==typeinfo(sizeof varr)