diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-01-14 23:37:04 -0800 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-01-15 15:11:37 -0800 |
| commit | a7bd1a631b9dd5b1221fdc0f3e4b299bda18138c (patch) | |
| tree | ed831fe0304bc647614f6ea5aba7582edea85559 /src/InternPool.zig | |
| parent | 204e689bdb74c5020a9201d20db976251f122250 (diff) | |
| download | zig-a7bd1a631b9dd5b1221fdc0f3e4b299bda18138c.tar.gz zig-a7bd1a631b9dd5b1221fdc0f3e4b299bda18138c.zip | |
wasm codegen: fix mistaking extern data as function
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index 9c91dfae6a..30a0dd087c 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -616,6 +616,20 @@ pub const Nav = struct { }; } + pub fn isFn(nav: Nav, ip: *const InternPool) bool { + return switch (nav.status) { + .unresolved => unreachable, + .type_resolved => |r| { + const tag = ip.zigTypeTagOrPoison(r.type) catch unreachable; + return tag == .@"fn"; + }, + .fully_resolved => |r| { + const tag = ip.zigTypeTagOrPoison(ip.typeOf(r.val)) catch unreachable; + return tag == .@"fn"; + }, + }; + } + /// If this returns `true`, then a pointer to this `Nav` might actually be encoded as a pointer /// to some other `Nav` due to an extern definition or extern alias (see #21027). /// This query is valid on `Nav`s for whom only the type is resolved. |
