From 58c3e6740989168cd2bf9847bda68a43aa1a6897 Mon Sep 17 00:00:00 2001 From: imxyy_soope_ Date: Thu, 22 Jan 2026 16:46:11 +0800 Subject: [PATCH] fix: force the attrset before checking its type in Nix.hasAttr --- nix-js/runtime-ts/src/helpers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nix-js/runtime-ts/src/helpers.ts b/nix-js/runtime-ts/src/helpers.ts index c48e31e..3c5689c 100644 --- a/nix-js/runtime-ts/src/helpers.ts +++ b/nix-js/runtime-ts/src/helpers.ts @@ -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)]);