fix: force the attrset before checking its type in Nix.hasAttr

This commit is contained in:
2026-01-22 16:46:11 +08:00
parent 7679a3b67f
commit 58c3e67409

View File

@@ -265,10 +265,11 @@ function selectWithDefault_impl(obj: NixValue, attrpath: NixValue[], default_val
}
export const hasAttr = (obj: NixValue, attrpath: NixValue[]): NixBool => {
if (!isAttrs(obj)) {
const forced = force(obj);
if (!isAttrs(forced)) {
return false;
}
let attrs = obj;
let attrs = forced;
for (const attr of attrpath.slice(0, -1)) {
const cur = force(attrs[forceString(attr)]);