Zcu: fix nav_ty dependency on nav_val

In the case where a declaration has no type annotation, the interaction
between resolution of `nav_ty` and `nav_val` is a little fiddly because
of the fact that resolving `nav_val` actually implicitly resolves the
type as well. This means `nav_ty` never gets an opporunity to mark its
dependency on the `nav_val`. So, `ensureNavValUpToDate` needs to be the
one to do it. It can't do it too early, though; otherwise, our marking
of dependees as out-of-date/up-to-date will go wrong.

Resolves: #23959
This commit is contained in:
mlugg
2025-05-25 04:40:59 +01:00
parent aeed5f9ebd
commit 3d8e760552
2 changed files with 75 additions and 28 deletions

View File

@@ -0,0 +1,30 @@
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#target=wasm32-wasi-selfhosted
#update=initial version
#file=main.zig
const foo = @as(u8, 123);
comptime {
// depends on value of `foo`
if (foo != 123) unreachable;
}
comptime {
// depends on type of `foo`
if (@TypeOf(&foo) != *const u8) unreachable;
}
pub fn main() void {}
#expect_stdout=""
#update=change the type
#file=main.zig
const foo = @as(u16, 123);
comptime {
// depends on value of `foo`
if (foo != 123) unreachable;
}
comptime {
// depends on type of `foo`
if (@TypeOf(&foo) != *const u8) unreachable;
}
pub fn main() void {}
#expect_error=main.zig:8:37: error: reached unreachable code