diff options
author | Nguyễn Gia Phong <cnx@loang.net> | 2025-08-25 00:54:37 +0900 |
---|---|---|
committer | Nguyễn Gia Phong <cnx@loang.net> | 2025-08-25 00:54:37 +0900 |
commit | 7d61d53d2e6c33b7bb847f608f43e2775fa3da9b (patch) | |
tree | b717a9d44651892d99e66cd97e33c351ce66f703 /src | |
parent | 38d2121984a23ed7a5ba83e072ae6ea9cedb55ac (diff) | |
download | zsanett-main.tar.gz |
Diffstat (limited to 'src')
-rw-r--r-- | src/root.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/root.zig b/src/root.zig index 0e26e33..a2561bf 100644 --- a/src/root.zig +++ b/src/root.zig @@ -344,11 +344,13 @@ pub fn eval(comptime T: type, str: []const u8, var ret: Value = undefined; const errflags = janet.dobytes(root_env, str.ptr, @intCast(str.len), src, &ret); - return if (errflags == 0) .{ - .ret = try unwrap(T, ret) - } else .{ - .err = try unwrap([]const u8, ret) // TODO: trace - }; + if (errflags == 0) { + return .{ .ret = try unwrap(T, ret) }; + } else { + const string = janet.unwrapString(ret); + const len = janet.stringLength(string); + return .{ .err = string[0..@intCast(len)] }; // TODO: trace + } } test eval { |