aboutsummaryrefslogtreecommitdiff
path: root/src/InternPool.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-01-14 23:37:04 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-01-15 15:11:37 -0800
commita7bd1a631b9dd5b1221fdc0f3e4b299bda18138c (patch)
treeed831fe0304bc647614f6ea5aba7582edea85559 /src/InternPool.zig
parent204e689bdb74c5020a9201d20db976251f122250 (diff)
downloadzig-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.zig14
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.