| author | |
| committer | |
| log | 7591df5172e9f8e80130b619b7eaa60846d3e851 |
| tree | 594c4abce2d54638c4d2c8b402d3ed3e520bfb81 |
| parent | 9232425b8f68e84d192c9c77ca0c3b7b2547d195 |
`ip.get` specifically doesn't allow `extern_func` keys to access it.2 files changed, 15 insertions(+), 3 deletions(-)
src/InternPool.zig+2-3| ... | ... | @@ -9433,12 +9433,11 @@ pub fn getCoerced( |
| 9433 | 9433 | switch (ip.indexToKey(val)) { |
| 9434 | 9434 | .undef => return ip.get(gpa, tid, .{ .undef = new_ty }), |
| 9435 | 9435 | .extern_func => |extern_func| if (ip.isFunctionType(new_ty)) |
| 9436 | return ip.get(gpa, tid, .{ .extern_func = .{ | |
| 9436 | return ip.getExternFunc(gpa, tid, .{ | |
| 9437 | 9437 | .ty = new_ty, |
| 9438 | 9438 | .decl = extern_func.decl, |
| 9439 | 9439 | .lib_name = extern_func.lib_name, |
| 9440 | } }), | |
| 9441 | ||
| 9440 | }), | |
| 9442 | 9441 | .func => unreachable, |
| 9443 | 9442 | |
| 9444 | 9443 | .int => |int| switch (ip.indexToKey(new_ty)) { |
test/behavior/extern.zig+13| ... | ... | @@ -45,3 +45,16 @@ test "function extern symbol matches extern decl" { |
| 45 | 45 | export fn another_mystery_function() u32 { |
| 46 | 46 | return 12345; |
| 47 | 47 | } |
| 48 | ||
| 49 | extern fn c_extern_function() [*c]u32; | |
| 50 | ||
| 51 | test "coerce extern function types" { | |
| 52 | const S = struct { | |
| 53 | export fn c_extern_function() [*c]u32 { | |
| 54 | return null; | |
| 55 | } | |
| 56 | }; | |
| 57 | _ = S; | |
| 58 | ||
| 59 | _ = @as(fn () callconv(.C) ?*u32, c_extern_function); | |
| 60 | } |