about summary refs log tree commit diff
path: root/src/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/root.zig b/src/root.zig
index d4f55dc..1ce21b3 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -139,7 +139,7 @@ pub fn wrap(x: anytype) !Value {
             entry.value_ptr.* = y;
             break :y c.janet_wrap_cfunction(y);
         },
-        .optional => try wrap(x orelse {}),
+        .optional => if (x) |child| try wrap(child) else try wrap({}),
         .pointer => |info| switch (info.size) {
             .one, .many, .c => c.janet_wrap_pointer(@constCast(@ptrCast(x))),
             .slice => y: {
@@ -252,7 +252,7 @@ pub fn unwrap(comptime T: type, x: Value) !T {
                     break :y entry.key_ptr.*;
             break :y error.UnknownFunction;
         },
-        .optional => |info| if (isNil(x)) null else unwrap(info.child, x),
+        .optional => |info| if (isNil(x)) null else try unwrap(info.child, x),
         .pointer => |info| switch (info.size) {
             .one, .many, .c => @alignCast(@ptrCast(c.janet_unwrap_pointer(x))),
             .slice => slice: {