From 1288356ceffeb370b7c5574059eb9a9197005c77 Mon Sep 17 00:00:00 2001 From: Lexy Plt Date: Mon, 11 May 2026 16:34:40 +0200 Subject: [PATCH 1/4] chore: remove internal builtin__list:slice and use builtin__slice implementation instead --- include/Ark/Builtins/Builtins.hpp | 1 - src/arkreactor/Builtins/Builtins.cpp | 2 +- src/arkreactor/Builtins/List.cpp | 32 ------------------- .../runtime/backtrace_builtin.expected | 18 +++++------ .../runtime/list_slice_end_start.ark | 1 - .../runtime/list_slice_end_start.expected | 6 ---- .../runtime/list_slice_past_end.ark | 1 - .../runtime/list_slice_past_end.expected | 6 ---- .../runtime/list_slice_start_less_0.ark | 1 - .../runtime/list_slice_start_less_0.expected | 6 ---- .../runtime/list_slice_step_null.ark | 1 - .../runtime/list_slice_step_null.expected | 6 ---- .../listslice_str_num_bool_nil.expected | 17 +++++++--- 13 files changed, 23 insertions(+), 75 deletions(-) delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.ark delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.expected delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.ark delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.expected delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.ark delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.expected delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.ark delete mode 100644 tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.expected diff --git a/include/Ark/Builtins/Builtins.hpp b/include/Ark/Builtins/Builtins.hpp index f4179cec7..de7cf86c5 100644 --- a/include/Ark/Builtins/Builtins.hpp +++ b/include/Ark/Builtins/Builtins.hpp @@ -38,7 +38,6 @@ namespace Ark::internal::Builtins { ARK_BUILTIN(reverseList); ARK_BUILTIN(findInList); - ARK_BUILTIN(sliceList); ARK_BUILTIN(sort_); ARK_BUILTIN(fill); ARK_BUILTIN(setListAt); diff --git a/src/arkreactor/Builtins/Builtins.cpp b/src/arkreactor/Builtins/Builtins.cpp index 4d499632b..1fa934cf5 100644 --- a/src/arkreactor/Builtins/Builtins.cpp +++ b/src/arkreactor/Builtins/Builtins.cpp @@ -30,7 +30,7 @@ namespace Ark::internal::Builtins // List { "builtin__list:reverse", Value(List::reverseList) }, { "builtin__list:find", Value(List::findInList) }, - { "builtin__list:slice", Value(List::sliceList) }, + { "builtin__list:slice", Value(slice) }, { "builtin__list:sort", Value(List::sort_) }, { "builtin__list:fill", Value(List::fill) }, { "builtin__list:setAt", Value(List::setListAt) }, diff --git a/src/arkreactor/Builtins/List.cpp b/src/arkreactor/Builtins/List.cpp index 15ea7dc2a..bc84143e0 100644 --- a/src/arkreactor/Builtins/List.cpp +++ b/src/arkreactor/Builtins/List.cpp @@ -33,38 +33,6 @@ namespace Ark::internal::Builtins::List return Value(-1); } - Value sliceList(std::vector& n, VM* vm [[maybe_unused]]) - { - if (!types::check(n, ValueType::List, ValueType::Number, ValueType::Number, ValueType::Number)) - throw types::TypeCheckingError( - "list:slice", - { { types::Contract { { types::Typedef("list", ValueType::List), - types::Typedef("start", ValueType::Number), - types::Typedef("end", ValueType::Number), - types::Typedef("step", ValueType::Number) } } } }, - n); - - const long step = static_cast(n[3].number()); - if (step <= 0) - throw std::runtime_error("list:slice: step can not be null or negative"); - - auto start = static_cast(n[1].number()); - auto end = static_cast(n[2].number()); - - if (start > end) - throw std::runtime_error(fmt::format("list:slice: start position ({}) must be less or equal to the end position ({})", start, end)); - if (start < 0) - throw std::runtime_error(fmt::format("list:slice: start index {} can not be less than 0", start)); - if (std::cmp_greater(end, n[0].list().size())) - throw std::runtime_error(fmt::format("list:slice: end index {} out of range (length: {})", end, n[0].list().size())); - - std::vector list; - for (auto i = static_cast(start); std::cmp_less(i, end); i += static_cast(step)) - list.push_back(n[0].list()[i]); - - return Value(std::move(list)); - } - Value sort_(std::vector& n, VM* vm [[maybe_unused]]) { if (!types::check(n, ValueType::List)) diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected index 4290a1dec..a79164e67 100644 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected +++ b/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected @@ -6,16 +6,16 @@ Signature Arguments → `list' (expected List), got "live" (String) -In file /lib/std/List.ark:51 - 48 | # (list:sort [4 2 3]) # [1 2 4] - 49 | # =end - 50 | # @author https://github.com/SuperFola - 51 | (let sort (fun (_L) (builtin__list:sort _L))) +In file /lib/std/List.ark:62 + 59 | # (list:sort [4 2 3]) # [1 2 4] + 60 | # =end + 61 | # @author https://github.com/SuperFola + 62 | (let sort (fun (_L) (builtin__list:sort _L))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 52 | - 53 | # @brief Generate a List of n copies of an element + 63 | + 64 | # @brief Generate a List of n copies of an element -[ 2] In function `list:sort' (/lib/std/List.ark:51) +[ 2] In function `list:sort' (/lib/std/List.ark:62) [ 1] In global scope (tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.ark:3) -Current scope variables values: \ No newline at end of file +Current scope variables values: diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.ark b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.ark deleted file mode 100644 index cd1a6ed16..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.ark +++ /dev/null @@ -1 +0,0 @@ -(builtin__list:slice [1 2 3 4 5 6 7 8 9] 6 5 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.expected deleted file mode 100644 index eb173fb86..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.expected +++ /dev/null @@ -1,6 +0,0 @@ -list:slice: start position (6) must be less or equal to the end position (5) - -In file tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_end_start.ark:1 - 1 | (builtin__list:slice [1 2 3 4 5 6 7 8 9] 6 5 1) - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 2 | diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.ark b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.ark deleted file mode 100644 index 0dc38a42b..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.ark +++ /dev/null @@ -1 +0,0 @@ -(builtin__list:slice [1 2 3 4 5 6 7 8 9] 6 12 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.expected deleted file mode 100644 index 91d099ba2..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.expected +++ /dev/null @@ -1,6 +0,0 @@ -list:slice: end index 12 out of range (length: 9) - -In file tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_past_end.ark:1 - 1 | (builtin__list:slice [1 2 3 4 5 6 7 8 9] 6 12 1) - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 2 | diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.ark b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.ark deleted file mode 100644 index 1cf0819d7..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.ark +++ /dev/null @@ -1 +0,0 @@ -(builtin__list:slice [1 2 3 4 5 6 7 8 9] -1 5 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.expected deleted file mode 100644 index ca22081e0..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.expected +++ /dev/null @@ -1,6 +0,0 @@ -list:slice: start index -1 can not be less than 0 - -In file tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_start_less_0.ark:1 - 1 | (builtin__list:slice [1 2 3 4 5 6 7 8 9] -1 5 1) - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 2 | diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.ark b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.ark deleted file mode 100644 index 58671609e..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.ark +++ /dev/null @@ -1 +0,0 @@ -(builtin__list:slice [1 2 3 4 5 6 7 8 9] 4 5 -1) diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.expected deleted file mode 100644 index 97a3aecbd..000000000 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.expected +++ /dev/null @@ -1,6 +0,0 @@ -list:slice: step can not be null or negative - -In file tests/unittests/resources/DiagnosticsSuite/runtime/list_slice_step_null.ark:1 - 1 | (builtin__list:slice [1 2 3 4 5 6 7 8 9] 4 5 -1) - | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 2 | diff --git a/tests/unittests/resources/DiagnosticsSuite/typeChecking/listslice_str_num_bool_nil.expected b/tests/unittests/resources/DiagnosticsSuite/typeChecking/listslice_str_num_bool_nil.expected index f66a79e75..4f9315750 100644 --- a/tests/unittests/resources/DiagnosticsSuite/typeChecking/listslice_str_num_bool_nil.expected +++ b/tests/unittests/resources/DiagnosticsSuite/typeChecking/listslice_str_num_bool_nil.expected @@ -1,10 +1,19 @@ -Function list:slice expected 4 arguments +Function slice expected between 3 arguments and 4 arguments Call - ↳ (list:slice "hello" 1 true nil) + ↳ (slice "hello" 1 true nil) Signature - ↳ (list:slice list start end step) + ↳ (slice container start end) Arguments - → `list' (expected List), got "hello" (String) + → `container' (expected List, or String) ✓ + → `start' (expected Number) ✓ + → `end' (expected Number), got true (Bool) + → unexpected additional args: nil (Nil) + +Alternative 2: +Signature + ↳ (slice container start end step) +Arguments + → `container' (expected List, or String) ✓ → `start' (expected Number) ✓ → `end' (expected Number), got true (Bool) → `step' (expected Number), got nil (Nil) From 6bc16e9fa528fa7f60eb54066d557729421be9b4 Mon Sep 17 00:00:00 2001 From: Lexy Plt Date: Mon, 11 May 2026 16:35:30 +0200 Subject: [PATCH 2/4] feat(builtins): add builtin__string:codepoints to compute the unicode codepoints of a string --- CHANGELOG.md | 29 +++++++++++++++++++ include/Ark/Builtins/Builtins.hpp | 1 + lib/std | 2 +- src/arkreactor/Builtins/Builtins.cpp | 1 + src/arkreactor/Builtins/String.cpp | 22 ++++++++++++++ .../ir/operators_as_builtins.expected | 2 +- .../optimized_ir/builtins.expected | 2 +- .../typeChecking/builtin_codepoints_num.ark | 1 + .../builtin_codepoints_num.expected | 12 ++++++++ 9 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.ark create mode 100644 tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.expected diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a9af3cf3..1f4e3fda4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Change Log +## [Unreleased changes] - 2026-MM-DD +### Breaking changes + +### Deprecations +- `std.Range` has been entirely deprecated and is scheduled for removal + +### Added +- standard library: + - list:slice1 + - list:first + - list:last + - list:cumulativeSum + - list:cumulativeProduct + - list:zeros + - list:ones + - string:lpad + - string:rpad + - string:ascii? + - string:first + - string:last + - string:codepoints +- new builtin `builtin__string:codepoints` returning the Unicode codepoints of a string as a list of numbers + +### Changed +- `$repr` shows the correct representation for macros +- `$symcat` accepts symbols and strings as its first argument + +### Removed + ## [4.5.2] - 2026-05-06 ### Changed - fix compiler segfault when there is no variable to mark as unreachable diff --git a/include/Ark/Builtins/Builtins.hpp b/include/Ark/Builtins/Builtins.hpp index de7cf86c5..039740d30 100644 --- a/include/Ark/Builtins/Builtins.hpp +++ b/include/Ark/Builtins/Builtins.hpp @@ -81,6 +81,7 @@ namespace Ark::internal::Builtins ARK_BUILTIN(ord); ARK_BUILTIN(chr); ARK_BUILTIN(setStringAt); + ARK_BUILTIN(codepoints); } namespace Mathematics diff --git a/lib/std b/lib/std index 0a1de1ec4..c82fd86bc 160000 --- a/lib/std +++ b/lib/std @@ -1 +1 @@ -Subproject commit 0a1de1ec49967d04f7683c74d4faf97fbaa08d8d +Subproject commit c82fd86bc7c6df9052544541564afd1439c3f2d2 diff --git a/src/arkreactor/Builtins/Builtins.cpp b/src/arkreactor/Builtins/Builtins.cpp index 1fa934cf5..138a9c1b2 100644 --- a/src/arkreactor/Builtins/Builtins.cpp +++ b/src/arkreactor/Builtins/Builtins.cpp @@ -67,6 +67,7 @@ namespace Ark::internal::Builtins { "builtin__string:ord", Value(String::ord) }, { "builtin__string:chr", Value(String::chr) }, { "builtin__string:setAt", Value(String::setStringAt) }, + { "builtin__string:codepoints", Value(String::codepoints) }, // Mathematics { "builtin__math:exp", Value(Mathematics::exponential) }, diff --git a/src/arkreactor/Builtins/String.cpp b/src/arkreactor/Builtins/String.cpp index f3d1b2bc3..464e21d7a 100644 --- a/src/arkreactor/Builtins/String.cpp +++ b/src/arkreactor/Builtins/String.cpp @@ -12,6 +12,7 @@ #include #include +#include struct value_wrapper { @@ -353,4 +354,25 @@ namespace Ark::internal::Builtins::String string[static_cast(idx)] = n[2].string()[0]; return n[0]; } + + Value codepoints(std::vector& n, VM* vm [[maybe_unused]]) + { + if (!types::check(n, ValueType::String)) + throw types::TypeCheckingError( + "string:codepoints", + { { types::Contract { { types::Typedef("string", ValueType::String) } } } }, + n); + + Value data(ValueType::List); + auto it = n[0].stringRef().begin(); + const auto end = n[0].stringRef().end(); + while (it != end) + { + auto [next, sym] = utf8_char_t::at(it, end); + data.push_back(Value(sym.codepoint())); + it = next; + } + + return data; + } } diff --git a/tests/unittests/resources/CompilerSuite/ir/operators_as_builtins.expected b/tests/unittests/resources/CompilerSuite/ir/operators_as_builtins.expected index 0377c5568..989649e3d 100644 --- a/tests/unittests/resources/CompilerSuite/ir/operators_as_builtins.expected +++ b/tests/unittests/resources/CompilerSuite/ir/operators_as_builtins.expected @@ -1,6 +1,5 @@ page_0 PUSH_RETURN_ADDRESS L0 - BUILTIN 70 BUILTIN 71 BUILTIN 72 BUILTIN 73 @@ -25,6 +24,7 @@ page_0 BUILTIN 92 BUILTIN 93 BUILTIN 94 + BUILTIN 95 CALL_BUILTIN 9, 25 .L0: POP 0 diff --git a/tests/unittests/resources/CompilerSuite/optimized_ir/builtins.expected b/tests/unittests/resources/CompilerSuite/optimized_ir/builtins.expected index 766179fe6..8cacabad9 100644 --- a/tests/unittests/resources/CompilerSuite/optimized_ir/builtins.expected +++ b/tests/unittests/resources/CompilerSuite/optimized_ir/builtins.expected @@ -5,7 +5,7 @@ page_0 HALT 0 page_1 - CALL_BUILTIN_WITHOUT_RETURN_ADDRESS 56, 1 + CALL_BUILTIN_WITHOUT_RETURN_ADDRESS 57, 1 .L0: RET 0 HALT 0 diff --git a/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.ark b/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.ark new file mode 100644 index 000000000..23bf12a31 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.ark @@ -0,0 +1 @@ +(builtin__string:codepoints 1) diff --git a/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.expected b/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.expected new file mode 100644 index 000000000..91f6a229a --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.expected @@ -0,0 +1,12 @@ +Function string:codepoints expected 1 argument +Call + ↳ (string:codepoints 1) +Signature + ↳ (string:codepoints string) +Arguments + → `string' (expected String), got 1 (Number) + +In file tests/unittests/resources/DiagnosticsSuite/typeChecking/builtin_codepoints_num.ark:1 + 1 | (builtin__string:codepoints 1) + | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + 2 | From ee657b6ca72722acc4e5fe178b549f0d99c05539 Mon Sep 17 00:00:00 2001 From: Lexy Plt Date: Wed, 13 May 2026 12:28:20 +0200 Subject: [PATCH 3/4] feat(macro): $symcat accepts a string or a symbol as its first argument --- src/arkreactor/Compiler/Macros/Processor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arkreactor/Compiler/Macros/Processor.cpp b/src/arkreactor/Compiler/Macros/Processor.cpp index 2c2e0314c..867350dff 100644 --- a/src/arkreactor/Compiler/Macros/Processor.cpp +++ b/src/arkreactor/Compiler/Macros/Processor.cpp @@ -528,7 +528,8 @@ namespace Ark::internal { if (node.list().size() <= 2) throwMacroProcessingError(fmt::format("When expanding `{}', expected at least 2 arguments, got {} arguments", Language::Symcat, argcount), node); - checkMacroTypeError(Language::Symcat.data(), "symbol", NodeType::Symbol, node.list()[1]); + if (node.list()[1].nodeType() != NodeType::Symbol && node.list()[1].nodeType() != NodeType::String) + checkMacroTypeError(Language::Symcat.data(), "symbol", NodeType::Symbol, node.list()[1]); std::string sym = node.list()[1].string(); From eae17351e05153c201941d455a3e9391243b463c Mon Sep 17 00:00:00 2001 From: Lexy Plt Date: Wed, 13 May 2026 12:28:45 +0200 Subject: [PATCH 4/4] fix(macro): $repr should be able to show the representation of a macro, when given one --- CHANGELOG.md | 1 + lib/std | 2 +- src/arkreactor/Compiler/Macros/Processor.cpp | 10 +++++++++- .../runtime/backtrace_builtin.expected | 16 ++++++++-------- .../resources/LangSuite/macro-tests.ark | 10 ++++++++-- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f4e3fda4..9d0e4a22b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ ### Changed - `$repr` shows the correct representation for macros - `$symcat` accepts symbols and strings as its first argument +- `math:pow` uses a more precise way of computing values when inputs are integers ### Removed diff --git a/lib/std b/lib/std index c82fd86bc..4c7bfb0cd 160000 --- a/lib/std +++ b/lib/std @@ -1 +1 @@ -Subproject commit c82fd86bc7c6df9052544541564afd1439c3f2d2 +Subproject commit 4c7bfb0cd07d19bfd0a5a27a452f7c91d7f20860 diff --git a/src/arkreactor/Compiler/Macros/Processor.cpp b/src/arkreactor/Compiler/Macros/Processor.cpp index 867350dff..2c617b888 100644 --- a/src/arkreactor/Compiler/Macros/Processor.cpp +++ b/src/arkreactor/Compiler/Macros/Processor.cpp @@ -585,7 +585,15 @@ namespace Ark::internal checkMacroArgCountEq(node, 1, Language::Repr.data(), true); const Node arg = node.constList()[1]; - node.updateValueAndType(Node(NodeType::String, arg.repr())); + if (arg.nodeType() == NodeType::Symbol) + { + if (const Node* arg_as_macro = findNearestMacro(arg.string()); arg_as_macro != nullptr) + node.updateValueAndType(Node(NodeType::String, arg_as_macro->repr())); + else + node.updateValueAndType(Node(NodeType::String, arg.repr())); + } + else + node.updateValueAndType(Node(NodeType::String, arg.repr())); } else if (name == Language::AsIs) { diff --git a/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected b/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected index a79164e67..a0322a85f 100644 --- a/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected +++ b/tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.expected @@ -6,16 +6,16 @@ Signature Arguments → `list' (expected List), got "live" (String) -In file /lib/std/List.ark:62 - 59 | # (list:sort [4 2 3]) # [1 2 4] - 60 | # =end - 61 | # @author https://github.com/SuperFola - 62 | (let sort (fun (_L) (builtin__list:sort _L))) +In file /lib/std/List.ark:63 + 60 | # (list:sort [4 2 3]) # [1 2 4] + 61 | # =end + 62 | # @author https://github.com/SuperFola + 63 | (let sort (fun (_L) (builtin__list:sort _L))) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - 63 | - 64 | # @brief Generate a List of n copies of an element + 64 | + 65 | # @brief Generate a List of n copies of an element -[ 2] In function `list:sort' (/lib/std/List.ark:62) +[ 2] In function `list:sort' (/lib/std/List.ark:63) [ 1] In global scope (tests/unittests/resources/DiagnosticsSuite/runtime/backtrace_builtin.ark:3) Current scope variables values: diff --git a/tests/unittests/resources/LangSuite/macro-tests.ark b/tests/unittests/resources/LangSuite/macro-tests.ark index d1e19071c..b4a5611e3 100644 --- a/tests/unittests/resources/LangSuite/macro-tests.ark +++ b/tests/unittests/resources/LangSuite/macro-tests.ark @@ -130,8 +130,14 @@ (test:case "builtin macros" { (macro nil-type ($type nil)) (macro bool-type ($type true)) - (test:eq "Nil" nil-type) - (test:eq "Bool" bool-type) }) + (macro show-repr (v) ($repr v)) + (test:eq nil-type "Nil") + (test:eq bool-type "Bool") + (test:eq (show-repr (macro a 5)) "(macro a 5)") + # function macros are evaluated on instantiation + (test:eq (show-repr show-repr) "(macro show-repr (v) ($repr v))") + # constant macros are evaluated on declaration + (test:eq (show-repr nil-type) "(macro nil-type \"Nil\")") }) (test:case "generate valid arkscript code with macros" { (macro make-func (retval) (fun () retval))