Skip to content

Show both attrPos and select pos in trace - #16249

Merged
xokdvium merged 3 commits into
NixOS:masterfrom
roberth:feat-attr-select-two-pos
Aug 5, 2026
Merged

Show both attrPos and select pos in trace#16249
xokdvium merged 3 commits into
NixOS:masterfrom
roberth:feat-attr-select-two-pos

Conversation

@roberth

@roberth roberth commented Jul 31, 2026

Copy link
Copy Markdown
Member

Motivation

tl;dr error context good.

1:
In a lazy language, any value may be fallible.
Fallible values are ok, as long as you don't eval them.
So in practice this is an acceptable pattern.

2:
Predicting whether a value fails requires more evaluation, making the expression less lazy.
For instance foo' = removeAttrs foo (f foo) can "sanitize" your foo, but makes foo' strict in f foo, which can be a problem.
So aforementioned pattern is desirable.

Given 1 and 2, not just the origin of a failure matters, but also where and how it is used.

Without this change, you may have no way to know who's responsible for accessing the failing attr.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@roberth
roberth requested a review from edolstra as a code owner July 31, 2026 13:11
@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Jul 31, 2026
@roberth roberth changed the title Feat attr select two pos Show both attrPos and select pos in trace Jul 31, 2026
Comment thread src/libexpr/parser.y
into `(rec {..., body = ...}).body'. */
| LET '{' binds '}'
{ $3->recursive = true; $3->pos = CUR_POS; $$ = state->exprs.add<ExprSelect>(state->exprs.alloc, noPos, $3, state->s.body); }
{ $3->recursive = true; $3->pos = CUR_POS; $$ = state->exprs.add<ExprSelect>(state->exprs.alloc, CUR_POS, $3, state->s.body); }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would gladly leave let/body alone, but this improvement keeps
the rest of the code tidy.

@roberth
roberth marked this pull request as draft July 31, 2026 13:36
@roberth
roberth force-pushed the feat-attr-select-two-pos branch from d7ca78f to 594d5c9 Compare July 31, 2026 16:32
@roberth
roberth marked this pull request as ready for review July 31, 2026 16:32
Comment thread tests/functional/repl/inherit-missing-shows-pos.expected
@roberth
roberth force-pushed the feat-attr-select-two-pos branch from 594d5c9 to 752ee13 Compare August 2, 2026 13:24
@roberth

roberth commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

(trivial rebase)

roberth added 3 commits August 6, 2026 00:11
Exercises `ExprSelect`'s source-distinguishing error trace on a
String source, making output changes observable, avoiding error
message regressions.

Assisted-By: Claude Opus 4.8
I would gladly leave let/body alone, but this improvement keeps
the rest of the code tidy.
*Foreshadowing* - this has no observable effect, because it's the
attribute's definition that tends to get printed.

Assisted-By: Claude Opus 4.8
Without this, you may have no way to know what's responsible for
accessing the wrong attr.

A `span` right in `ExprSelect` would be nice, but GC makes me a bit
wary of actually doing that, even though it is almost certainly fine.

Assisted-By: Claude Opus 4.8
@roberth
roberth force-pushed the feat-attr-select-two-pos branch from 752ee13 to 8c4d12e Compare August 5, 2026 22:15
@roberth

roberth commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

@xokdvium
xokdvium enabled auto-merge August 5, 2026 22:25
@xokdvium
xokdvium added this pull request to the merge queue Aug 5, 2026
Merged via the queue into NixOS:master with commit d476de7 Aug 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants