Skip to content

If a dynamic attribute name evaluates to null, remove it from the set - #220

Closed
shlevy wants to merge 2 commits into
NixOS:masterfrom
shlevy:null-dynamic-attrs
Closed

shlevy wants to merge 2 commits into
NixOS:masterfrom
shlevy:null-dynamic-attrs

Conversation

@shlevy

@shlevy shlevy commented Mar 9, 2014

Copy link
Copy Markdown
Member

No description provided.

@edolstra

Copy link
Copy Markdown
Member

Applied. Could you also add some documentation?

@edolstra edolstra closed this Mar 10, 2014
@shlevy
shlevy deleted the null-dynamic-attrs branch March 10, 2014 10:53
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
zolodev pushed a commit to zolodev/nix that referenced this pull request Jan 1, 2024
P-E-Meunier pushed a commit to P-E-Meunier/nix that referenced this pull request Feb 26, 2025
CertainLach pushed a commit to deltarocks/nix that referenced this pull request Nov 4, 2025
Just force evaluation in the background, no need to wait for it. If
the caller gets to a value before the worker threads do, no problem -
the caller will just do the evaluation instead, which is probably
faster.

Not waiting removes a deadlock possibility, where the calling thread
waits for some work items that are themselves waiting for a thunk that
is being evaluated by the calling thread. Fixes NixOS#220.
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
The helper introduced by NixOS#79 (`iterateFetcherAttrs` /
`FetcherAttrHandler` in `src/libexpr/primops/fetcher-attr-iter.hh`)
was scoped to the fetcher primops, but `prim_path` in `primops.cc`
has the same name-keyed dispatch shape: a five-way `if/else if`
chain over `path`/`name`/`filter`/`recursive`/`sha256` with a
uniform "unsupported argument '%1%' to 'builtins.path'" error tail.

This commit:

  - Renames the helper from `iterateFetcherAttrs` /
    `FetcherAttrHandler` to `iterateNamedAttrs` /
    `NamedAttrHandler` and the header from
    `fetcher-attr-iter.hh` to `named-attr-iter.hh`, so the name
    no longer suggests "fetcher-only" use.
  - Updates the three existing call sites
    (`prim_fetchClosure`, `prim_fetchMercurial`, the shared
    `fetch` helper behind `prim_fetchurl`/`prim_fetchTarball`)
    to the new names.
  - Migrates `prim_path` to use the helper. The text content of
    the user-visible diagnostic is preserved verbatim
    ("unsupported argument '<name>' to 'builtins.path'");
    diagnostic position remains `.atPos(attr.pos)` -- pointing
    at the offending attribute -- which matches both the
    pre-batch shape and the position the helper produces.

ANSI rendering note: the helper's format string is "unsupported
argument '%s' to '%s'", so the primop name (`builtins.path`,
`fetchClosure`, etc.) is now interpolated as a `%s` argument and
passes through the diagnostic's argument-coloring (Magenta).
Pre-batch hand-rolled `prim_path` baked the primop name into the
format string ("... to 'builtins.path'"), so it was rendered
uncoloured.  Same observation applies retroactively to the three
fetcher migrations under NixOS#79.  Text content of the rendered
diagnostic is unchanged; only the ANSI colouring of the primop
name differs.  No functional test asserts on either form.

Refs candidate NixOS#220.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
…amends

Two new candidates filed during Pass B reuse review when the
catalog gaps surfaced in the course of landing NixOS#79 and NixOS#85:

  - NixOS#220 (libexpr-extras): prim_path shares the iterateFetcherAttrs
    name-handler-table shape used by the fetcher primops.  Landed
    on vibe-coding/cleanup/libexpr; the helper was renamed
    iterateFetcherAttrs → iterateNamedAttrs and the header
    fetcher-attr-iter.hh → named-attr-iter.hh to drop the
    fetcher-flavoured name.

  - NixOS#221 (libutil-libstore-core-extras): BaseSetting<container<T>>
    parse/to_string/appendOrSet is hand-rolled across six
    specialisations.  Landed on vibe-coding/cleanup/libstore by
    lifting parseStoreReferenceCollection / renderStoreReferenceCollection
    into shipped configuration.hh as parseSettingTokens /
    renderSettingTokens.  Per-T scope notes recorded in the
    candidate body: only the StoreReference pair migrates;
    Strings/StringSet are already one-liners over tokenizeString;
    list/set<path> save one line each (not worth the indirection);
    set<ExperimentalFeature> has irreducible warn-on-unknown
    semantics.

The Pass-B follow-ups also amended:

  - NixOS#51 (libfetchers): unwrap single-field RefInfo struct to Hash;
    bundles the RefInfo deletion into the same delete-and-trim
    commit since the trim made it single-field.
  - NixOS#67 (libexpr): transpose primNumeric's 4×4 string-context
    ladders into a single per-Op NumOpDiag struct so the
    asymmetric "first of the multiplication" wording is visible
    at a glance.
  - NixOS#37, NixOS#163 (libutil): docstring polish (lifetime contract,
    intentionally-not-migrated note, PipeOptions class doc
    rewrite).
  - NixOS#100 (libstore): template forEachConfiguredSigner's printer to
    drop fun<> type erasure.
  - NixOS#135 (libstore): bundle AutoUserLock::acquire's startId/uidCount
    into a UidRange struct.
  - NixOS#74 (nix-cli): template runWholeStoreGC's printer to match
    runNarDump style.

INVENTORY.md catalog total updated 219+44 → 221+44.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
…xOS#221 + final adversarial pass

Extends the most-recent batch entry with:

  - Six Pass-B follow-up amends (categorised after the user asked
    which findings were caused by our changes versus pre-existing
    in source): libfetchers NixOS#51 RefInfo unwrap, libexpr NixOS#67
    NumOpDiag transpose, libutil NixOS#37/NixOS#163 docstring polish,
    libstore NixOS#100 template, libstore NixOS#135 UidRange struct, nix-cli
    NixOS#74 template.

  - Two new candidates filed and landed: NixOS#220 (libexpr,
    iterateFetcherAttrs → iterateNamedAttrs renamed and extended
    to prim_path) and NixOS#221 (libstore → libutil, parseSettingTokens
    / renderSettingTokens lifted into shipped configuration.hh).

  - Final adversarial review pass over those eight changes:
    libfetchers/libstore/nix-cli clean; libutil one minor
    (std::map::insert invalidation overclaim in fso::descendPath
    docstring, fixed); libexpr two minor (NixOS#220 commit body said
    "six-way" but pre-batch had only five attrs; ANSI coloring
    drift on the primop name now passing through %s coloring,
    acknowledged in commit body).

Final tip SHAs updated: libexpr 04f4a67fd, libfetchers 5df2ffc93,
libflake 02b9065c4, libstore 52963ff79, libutil 3e1bc0186, nix-cli
6692dfa88.  All six branches still Local-only past their pushed
tips; push policy is explicit-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 23, 2026
Bidirectional traceability audit (Pass-D-aftermath) found four
catalog Branch line texts whose code-description had drifted away
from the actual implementation after the Pass-B follow-up amends:

  - NixOS#100 Branch line: said `forEachConfiguredSigner` extracted
    "using `fun<void(LocalSigner &)>`"; the helper is actually a
    `template<class Callback> static void(const Callback &)`.
  - NixOS#74 Branch line: didn't mention that `runWholeStoreGC` is
    templated on the printer callback type.
  - NixOS#135 Branch line: said `AutoUserLock::acquire` "now takes
    startId/uidCount as plain parameters"; it actually takes a
    single file-local `UidRange` struct.
  - NixOS#51 Branch line: didn't mention that the now-single-field
    `RefInfo` struct itself was unwrapped to use `Hash` directly.

Plus one factual error in the candidate body of NixOS#220 itself: the
opening sentence enumerated a "six-way" chain over
`name`/`path`/`filter`/`recursive`/`sha256`/`method`, but pre-batch
`prim_path` had only five handlers (`method` is computed from the
boolean `recursive` attribute, not as a separate handler). The
commit body of the implementing commit was already corrected; this
fixes the catalog body to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
The helper introduced by NixOS#79 (`iterateFetcherAttrs` /
`FetcherAttrHandler` in `src/libexpr/primops/fetcher-attr-iter.hh`)
was scoped to the fetcher primops, but `prim_path` in `primops.cc`
has the same name-keyed dispatch shape: a five-way `if/else if`
chain over `path`/`name`/`filter`/`recursive`/`sha256` with a
uniform "unsupported argument '%1%' to 'builtins.path'" error tail.

This commit:

  - Renames the helper from `iterateFetcherAttrs` /
    `FetcherAttrHandler` to `iterateNamedAttrs` /
    `NamedAttrHandler` and the header from
    `fetcher-attr-iter.hh` to `named-attr-iter.hh`, so the name
    no longer suggests "fetcher-only" use.
  - Updates the three existing call sites
    (`prim_fetchClosure`, `prim_fetchMercurial`, the shared
    `fetch` helper behind `prim_fetchurl`/`prim_fetchTarball`)
    to the new names.
  - Migrates `prim_path` to use the helper. The text content of
    the user-visible diagnostic is preserved verbatim
    ("unsupported argument '<name>' to 'builtins.path'");
    diagnostic position remains `.atPos(attr.pos)` -- pointing
    at the offending attribute -- which matches both the
    pre-batch shape and the position the helper produces.

ANSI rendering note: the helper's format string is "unsupported
argument '%s' to '%s'", so the primop name (`builtins.path`,
`fetchClosure`, etc.) is now interpolated as a `%s` argument and
passes through the diagnostic's argument-coloring (Magenta).
Pre-batch hand-rolled `prim_path` baked the primop name into the
format string ("... to 'builtins.path'"), so it was rendered
uncoloured.  Same observation applies retroactively to the three
fetcher migrations under NixOS#79.  Text content of the rendered
diagnostic is unchanged; only the ANSI colouring of the primop
name differs.  No functional test asserts on either form.

Refs candidate NixOS#220.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
ConnorBaker added a commit to ConnorBaker/nix that referenced this pull request May 24, 2026
…op diagnostic shifts

After candidate NixOS#109, the canonical declaration of `nix::isVarName`
moved from `src/libexpr/print.cc` to `src/libexpr/include/nix/expr/
print.hh` (with the lexer-mirror invariant restated in the docstring
there). The pinning comment in `lexer.l`'s ID rule still pointed at
the .cc file. Retarget to the header.

Add doc/manual/rl-next/primop-diagnostic-position.md documenting the
position-anchor and ANSI-colouring shift for `builtins.fetchurl`,
`builtins.fetchTarball`, `builtins.fetchGit`, and `builtins.path`
that landed under candidates NixOS#79 and NixOS#220. The wording of existing
diagnostics is otherwise unchanged.

Refs candidates NixOS#109, NixOS#79, NixOS#220.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
roberth added a commit to roberth/nix that referenced this pull request Aug 9, 2026
…orHash → reqHash

Under the "Observation = scoped Fact" framing, this type carries no
in-object scope — the containing vector<> → SelectorCallbackApply.argObsSet
provides the (one-callback-firing) attribution externally. It's a Fact.

TracingDecisionGraph::Fact already exists as the hash-only FactSet member,
so pick InlineFact to disambiguate on the physical shape: the obsSet
member inlines its response as CBOR bytes so callback replay is one CAS
lookup instead of two. The inline-response shape is load-bearing.

The field rename (selectorHash → reqHash) makes the parallel with the
neighbouring hash-only Fact visible and mirrors nix::Observation.reqHash.
The container establishes "Selector-shaped requests"; the field name
doesn't need to re-encode it.

Suite unchanged: 325/3/7 (same pre-existing cb-higher-order failures).

Assisted-by: Claude Code (Claude Opus 4.7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants