Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getter can't return a Callback #200

Open
krichprollsch opened this issue Feb 7, 2024 · 0 comments
Open

getter can't return a Callback #200

krichprollsch opened this issue Feb 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@krichprollsch
Copy link
Member

A getter can't return a Callback

diff --git a/src/tests/cbk_test.zig b/src/tests/cbk_test.zig
index 4f7bf0e..74b089a 100644
--- a/src/tests/cbk_test.zig
+++ b/src/tests/cbk_test.zig
@@ -18,6 +18,8 @@ pub const OtherCbk = struct {
 };
 
 pub const Window = struct {
+    cbk: Callback = undefined,
+
     pub fn constructor() Window {
         return Window{};
     }
@@ -59,6 +61,14 @@ pub const Window = struct {
         // ignore the error to let the JS msg
     }
 
+    pub fn get_cbk(self: Window) Callback {
+        return self.cbk;
+    }
+
+    pub fn set_cbk(self: *Window, callback: Callback) void {
+        self.cbk = callback;
+    }
+
     pub fn deinit(_: *Window, _: std.mem.Allocator) void {}
 };
 
@@ -212,4 +222,11 @@ pub fn exec(
         },
     };
     try tests.checkCases(js_env, &cases_cbk_async_with_nat_arg);
+
+    // getter cbk
+    var cases_cbk_getter_arg = [_]tests.Case{
+        .{ .src = "window.cbk =  () => {};", .ex = "() => {}" },
+        .{ .src = "window.cbk", .ex = "() => {}" },
+    };
+    try tests.checkCases(js_env, &cases_cbk_getter_arg);
 }
panic: attempt to unwrap error: NativeTypeUnhandled                                                             
/home/pierre/wrk/browsercore/vendor/jsruntime-lib/src/engines/v8/types_primitives.zig:46:17: 0xa9551f in nativeToJS__anon_22656 (test)
        else => return error.NativeTypeUnhandled,                                                               
                ^                                                                                               
/home/pierre/wrk/browsercore/vendor/jsruntime-lib/src/engines/v8/generate.zig:672:13: 0xa955e1 in setNativeType__anon_22655 (test)
    ) catch unreachable; // NOTE: should not happen has types have been checked at reflect                      
            ^          
/home/pierre/wrk/browsercore/vendor/jsruntime-lib/src/engines/v8/generate.zig:860:37: 0xa22bcc in callFunc__anon_21045 (test)
        const js_val = setNativeType(                                                                           
                                    ^                                                                                                                                                                                            
/home/pierre/wrk/browsercore/vendor/jsruntime-lib/src/engines/v8/generate.zig:926:21: 0x9f626e in getter (test) 
            callFunc(                                                                                           
                    ^                                                                                           
../../../../v8/src/api/api-arguments-inl.h:201:3: 0x16ecbb0 in BasicCallNamedGetterCallback (../../../../v8/src/objects/objects.cc)
../../../../v8/src/api/api-arguments-inl.h:315:10: 0x16c4777 in CallAccessorGetter (../../../../v8/src/objects/objects.cc)
../../../../v8/src/objects/objects.cc:1442:34: 0x16c2d19 in GetPropertyWithAccessor (../../../../v8/src/objects/objects.cc)
../../../../v8/src/objects/objects.cc:1185:16: 0x16c1843 in GetProperty (../../../../v8/src/objects/objects.cc)
../../../../v8/src/ic/ic.cc:507:5: 0x2733528 in Load (../../../../v8/src/ic/ic.cc)
../../../../v8/src/ic/ic.cc:2675:3: 0x27428ce in __RT_impl_Runtime_LoadNoFeedbackIC_Miss (../../../../v8/src/ic/ic.cc)
../../../../v8/src/ic/ic.cc:2660:1: 0x27423f7 in Runtime_LoadNoFeedbackIC_Miss (../../../../v8/src/ic/ic.cc)
???:?:?: 0xffc5fe in ??? (???)
Unwind error at address `:0xffc5fe` (error.AddressOutOfRange), trace may be incomplete
@krichprollsch krichprollsch added the bug Something isn't working label Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant