zig icon indicating copy to clipboard operation
zig copied to clipboard

Compiler crash with extern function returning opaque

Open PauloCampana opened this issue 1 year ago • 1 comments

code:

const opq = opaque {};
extern fn fnname() opq;

test {
    _ = &fnname;
}

results:

$ zig version
0.13.0
$ zig test opaque.zig 
opaque.zig:2:20: error: opaque return type 'opaque.opq' not allowed
extern fn fnname() opq;
                   ^~~
opaque.zig:1:13: note: opaque declared here
const opq = opaque {};
            ^~~~~~~~~
$ zig14 version
0.14.0-dev.1080+da8fbcc2a
$ zig14 test opaque.zig 
Trace/breakpoint trap (core dumped)

Both compilers are x86_64 linux downloaded from the website

PauloCampana avatar Aug 16 '24 05:08 PauloCampana

It does cause a compile error but the function is still sent to the backend.

$ zig-dev test a.zig -fno-emit-bin 
a.zig:4:20: error: opaque return type 'a.opq' not allowed
extern fn fnname() opq;
                   ^~~
a.zig:3:13: note: opaque declared here
const opq = opaque {};
            ^~~~~~~~~

Vexu avatar Aug 16 '24 09:08 Vexu