Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird interaction between between recursive attribute sets and nested attribute shorthand. #6251

Open
Gaelan opened this issue Mar 13, 2022 · 2 comments

Comments

@Gaelan
Copy link

Gaelan commented Mar 13, 2022

Describe the bug

In an attribute set with a nested recursive attribute set, values defined in the recursive attribute set are visible in attributes defined outside of the rec block.

Steps To Reproduce

In a Nix REPL, evaluate the expression { a = rec { b = 5; }; a.c = b; }

Expected behavior

The expression errors, either saying that b is out of scope or that defining both a = rec {...}; and a.c = ... is not permitted.

Actual behavior

The expression evaluates to { a = { b = 5; c = 5; }; }.

nix-env --version output

nix-env (Nix) 2.7.0pre20220221_caf5172
@Gaelan Gaelan added the bug label Mar 13, 2022
@puckipedia
Copy link
Contributor

This behaves the same without the shorthand as well: { a = rec { b = 5; }; a = { c = b; }; }

@pennae
Copy link
Contributor

pennae commented Mar 14, 2022

it's important to note that both of these are just syntactic sugar, they're merged to { a = rec { b = 5; c = b; }; } during parsing.

@stale stale bot added the stale label Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants