How to typecheck an entire file or project, including unused functions?

From what I can tell, zls checks syntax but not types, and the Zig compiler only typechecks code paths that are actually used; if you define a public function but don’t call it anywhere in your project, there’s no way to tell if it’s type-correct.

I’m not sure If I’m doing something wrong or if this is an intrinsic limitation of Zig. Is the only way to typecheck a file to write a test for every function it defines? Seems like it would be easy to miss something, since there’s no way to check test coverage.

1 Like

I think you can write a test where you simply invoke std.testing.refAllDeclsRecursive on the main fn (if thats possible but I dont see why not) and then invoke zig build test or zig test …

1 Like

I recommend reading through the source of refalldecls too, its genuinely interesting and smart