Naked package .paths ignored on cache hit

After seeing #37340, I tried it out on the latest Zig master.

After running zig fetch --save=zlib https://github.com/madler/zlib/archive/refs/tags/v1.3.2.tar.gz, I got:

.zlib = .{
    .url = "https://github.com/madler/zlib/archive/refs/tags/v1.3.2.tar.gz",
    .hash = "N-V-__8AAI4ANwDM8MWhHTUFLKfvLE_n2NQk6mh0sFDzhTqO",
},

Then I added .version and .paths following the devlog example, and updated the hash as suggested by zig build:

.dependencies = .{
    .zlib = .{
        .url = "https://github.com/madler/zlib/archive/refs/tags/v1.3.2.tar.gz",
        .hash = "zlib-1.3.2-__8AAE4XAAC21d06uJE2hn8zM08NWkk1Pucg7nF2EhxU",
        .version = "1.3.2",
        .paths = .{
            "LICENSE",
            "adler32.c",
        },
    },
},

Everything worked fine. The directory in zig-pkg/ contained only LICENSE and adler32.c, just as expected.

But when I removed "LICENSE" from .paths and ran zig build again, it still succeeded without any errors.

After deleting zig-pkg/ and running zig build again, I got a hash mismatch:

➜ zig build                                                                           
./build.zig.zon:9:21: error: hash mismatch: manifest declares zlib-1.3.2-__8AAE4XAAC21d06uJE2hn8zM08NWkk1Pucg7nF2EhxU but the fetched package has zlib-1.3.2-__8AAGQTAAAlmU9ZwciW_O9jqigakC_zlOKmE3eZ9vJO
            .hash = "zlib-1.3.2-__8AAE4XAAC21d06uJE2hn8zM08NWkk1Pucg7nF2EhxU",
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From what I understand, Zig looks up the package by the declared hash and uses the cached package if it exists, without reapplying the current .paths.

I don’t quite understand why the result should depend on whether the package is already cached. Is this intentional, or just an overlooked edge case?

I would say definitely a bug even if its intended as your project may depend on that path you just removed which would result in an error if it wasn’t already cached.