• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 14316379818

07 Apr 2025 06:10PM UTC coverage: 80.073% (+0.7%) from 79.378%
14316379818

push

github

SuperFola
feat(tests, type checker): adding tests for the type checker error message generation (in isolation)

36 of 68 new or added lines in 2 files covered. (52.94%)

12 existing lines in 3 files now uncovered.

6128 of 7653 relevant lines covered (80.07%)

77599.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.75
/src/arkreactor/Builtins/Async.cpp
1
#include <Ark/Builtins/Builtins.hpp>
2

3
#include <memory>
4
#include <thread>
5

6
#include <Ark/Constants.hpp>
7
#include <Ark/TypeChecker.hpp>
8
#include <Ark/VM/VM.hpp>
9

10
namespace Ark::internal::Builtins::Async
11
{
12
    /**
13
     * @name async
14
     * @brief Calls a function asynchronously with a given set of arguments
15
     * @details The function is started in a separate context, with no access to the others, preventing any concurrency problems.
16
     * @param func the function to call
17
     * @param args... the arguments of the function
18
     * =begin
19
     * (let foo (fun (a b) (+ a b)))
20
     * (async foo 1 2)
21
     * =end
22
     * @author https://github.com/SuperFola
23
     */
UNCOV
24
    Value async(std::vector<Value>& n, VM* vm)
×
UNCOV
25
    {
×
UNCOV
26
        if (n.empty() || (n[0].valueType() != ValueType::PageAddr && n[0].valueType() != ValueType::CProc && n[0].valueType() != ValueType::Closure))
×
27
            types::generateError(
×
28
                "async", { { types::Contract { { types::Typedef("function", { ValueType::PageAddr, ValueType::CProc, ValueType::Closure }), types::Typedef("args", ValueType::Any, /* is_variadic= */ true) } }, types::Contract { { types::Typedef("function", { ValueType::PageAddr, ValueType::CProc, ValueType::Closure }) } } } }, n);
×
29

UNCOV
30
        Future* future = vm->createFuture(n);
×
UNCOV
31
        return Value(UserType(future));
×
UNCOV
32
    }
×
33

34
    /**
35
     * @name await
36
     * @brief Blocks until the result becomes available
37
     * @details
38
     * @param future the future to wait for its result to be available
39
     * =begin
40
     * (let foo (fun (a b) (+ a b)))
41
     * (let async-foo (async foo 1 2))
42
     * (print (await async-foo))
43
     * =end
44
     * @author https://github.com/SuperFola
45
     */
46
    Value await(std::vector<Value>& n, VM* vm [[maybe_unused]])
7✔
47
    {
7✔
48
        if (!types::check(n, ValueType::User) || !n[0].usertypeRef().is<Future>())
7✔
49
            types::generateError("await", { { types::Contract { { types::Typedef("future", ValueType::User) } } } }, n);
×
50

51
        auto& f = n[0].usertypeRef().as<Future>();
7✔
52
        Value res = f.resolve();
7✔
53

54
        return res;
7✔
55
    }
7✔
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc