mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
ip: use getExternFunc in getCoerced
`ip.get` specifically doesn't allow `extern_func` keys to access it.
This commit is contained in:
parent
9232425b8f
commit
7591df5172
@ -9433,12 +9433,11 @@ pub fn getCoerced(
|
||||
switch (ip.indexToKey(val)) {
|
||||
.undef => return ip.get(gpa, tid, .{ .undef = new_ty }),
|
||||
.extern_func => |extern_func| if (ip.isFunctionType(new_ty))
|
||||
return ip.get(gpa, tid, .{ .extern_func = .{
|
||||
return ip.getExternFunc(gpa, tid, .{
|
||||
.ty = new_ty,
|
||||
.decl = extern_func.decl,
|
||||
.lib_name = extern_func.lib_name,
|
||||
} }),
|
||||
|
||||
}),
|
||||
.func => unreachable,
|
||||
|
||||
.int => |int| switch (ip.indexToKey(new_ty)) {
|
||||
|
||||
@ -45,3 +45,16 @@ test "function extern symbol matches extern decl" {
|
||||
export fn another_mystery_function() u32 {
|
||||
return 12345;
|
||||
}
|
||||
|
||||
extern fn c_extern_function() [*c]u32;
|
||||
|
||||
test "coerce extern function types" {
|
||||
const S = struct {
|
||||
export fn c_extern_function() [*c]u32 {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
_ = S;
|
||||
|
||||
_ = @as(fn () callconv(.C) ?*u32, c_extern_function);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user